def signin(): ''' Verify and signin a user. ''' user = None user_verified = False pass_verified = False next = request.args.get('next', None) if request.method == 'POST': try: user = User.query(User.username == request.form.get( 'username', '')).get() # NOQA except Exception as ex: pass user_verified = True if user else False if (user and user.password and User.password.verify( request.form.get('password'), user.password)): sec.token = {'usr': user.username, 'uid': user.uid} pass_verified = True return redirect(next or url_for('root')) else: user = User() user.fill(username=request.form.get('username')) return render_template('signin.html', page=None, user=user, form_action=url_for('signin', next=next), next=next, user_verified=user_verified, pass_verified=pass_verified)
def login(): user = None pass_verified = False if request.method == 'POST': user = User.query(User.username == request.form.get('username')).get() if not user: user = User() user.fill(username=request.form.get('username')) if (user and user.password and User.password.verify(request.form.get('password'), user.password)): sec.token = {'username': user.username} pass_verified = True return redirect(url_for('auth.welcome')) try: return render_template('login.html', auth=user, pass_verified=pass_verified) except TemplateNotFound: abort(404)
def get_all_users(): # choices for select field all_users = User.query().order(User.family_name) all_users_list = yield all_users.map_async(lambda x: (x.key.urlsafe( ), str(x.given_name) + ' ' + str(x.family_name))) raise ndb.Return(all_users_list)
def get_all_users(): # choices for select field all_users = User.query().order(User.family_name) all_users_list = yield all_users.map_async(lambda x: (x.key.urlsafe(), str(x.given_name) + ' ' + str(x.family_name))) raise ndb.Return(all_users_list)