def _init_auth_datastore(datastore): # If it's a fresh database, create an initial admin user. if not User.table_exists(): for Model in (User, Role, UserRoles): Model.create_table(fail_silently=True) initial_admin_email = '*****@*****.**' from random import _urandom initial_admin_password = \ _urandom(12).encode('base-64')[:-2] admin_user = datastore.create_user( email=initial_admin_email, password=encrypt_password(initial_admin_password), active=True) admin_role = datastore.create_role(name='admin') flash("""Fresh installation: Login as "{}" with password "{}", and change your email and password via the user admin interface. This message only appears once!""".format( initial_admin_email, initial_admin_password), "danger") datastore.add_role_to_user(admin_user, admin_role) logout_user() # in case there's a stale cookie # This is *always* done (in case new roles were added) # Heads up: USER_ROLES are hard-coded at __init__.py for role_name in current_app.config['USER_ROLES']: if not datastore.find_role(role_name): datastore.create_role(name=role_name)
def logout(): """ Logout user. @login_required :return: """ logout_user() return {}
def shop_uninstall_app(shop_id): """ Shop gets uninstalled cleanly **Access** * Shop owner """ shopify.clean_uninstall_shop.delay(shop_id) logout_user() return generate_success_response_from_obj(success_message=assets.ExceptionMessages.UNINSTALLED)
def oauth_authenticate(client_id, user, require_existing_link=False, remember=False): """Authenticate an oauth authorized callback.""" # Authenticate via the access token (access token used to get user_id) if login_user(user): if require_existing_link: account = RemoteAccount.get(user.id, client_id) if account is None: logout_user() return False return True return False
def oauth_authenticate(client_id, user, require_existing_link=False, remember=False): """Authenticate an oauth authorized callback. :param client_id: The client id. :param user: A user instance. :param require_existing_link: If ``True``, check if remote account exists. (Default: ``False``) :returns: ``True`` if the user is successfully authenticated. """ # Authenticate via the access token (access token used to get user_id) if not requires_confirmation(user): after_this_request(_commit) if login_user(user, remember=remember): if require_existing_link: account = RemoteAccount.get(user.id, client_id) if account is None: logout_user() return False return True return False
def test_signup_handler(remote, models_fixture): """Test signup handler.""" app = models_fixture datastore = app.extensions['invenio-accounts'].datastore existing_email = '*****@*****.**' user = datastore.find_user(email=existing_email) # Already authenticated login_user(user) assert current_user.is_authenticated resp1 = signup_handler(remote) check_redirect_location(resp1, '/') logout_user() assert not current_user.is_authenticated # No OAuth token resp2 = signup_handler(remote) check_redirect_location(resp2, '/') # Not coming from authorized request token = RemoteToken.create(user.id, 'testkey', 'mytoken', 'mysecret') token_setter(remote, token, 'mysecret') with pytest.raises(BuildError): signup_handler(remote)
def delete(self, **kwargs): '''Delete my profile''' user = current_user._get_current_object() user.mark_as_deleted() logout_user() return '', 204
def logout_or_renew_anonymous_user_id(): logout_user() session['anonymous_user_id'] = None user = get_real_or_anonymous_user() return str(user.id)
def logout_view(self): logout_user() return redirect(url_for('.login_view'))
def logout(): flask_security.logout_user() return redirect(url_for('/'))
def logout(): logout_user() flash('You have been logged out.', 'info') return redirect(url_for('public.home'))
def logout(): logout_user() set_current_user(current_user) return redirect(url_for('.index'))
def index(self): logout_user() return redirect('/login?next=/admin')
def index(self): logout_user() return redirect('/admin')
def logout_user(client): """Log current user out.""" flask_security.logout_user() with client.session_transaction() as session: session.pop("user_id", None)
def log_out(): logout_user() return redirect(request.args.get('next') or '/')
def logout(): """ Logout. """ logout_user() return redirect(url_for('webuiview.index'))
def logout(): flash(u'Çıkış yaptınız', 'info') logout_user() return redirect("/login")
def logout(): from flask_login import current_user user = current_user user.authenticated = False logout_user()