SHARE
TWEET

Untitled

a guest Dec 13th, 2016 73 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. @user.route('/signin', methods=['GET', 'POST'])
  2. def signin():
  3.     """ Login a user
  4.     """
  5.     form = SigninForm(request.form)
  6.     if request.method == 'POST' and form.validate():
  7.         username = form.username.data
  8.         password = form.password.data
  9.  
  10.         if username:
  11.             try:
  12.                 user = User.objects.get( username = username )
  13.             except User.DoesNotExist:
  14.                 form.username.errors = ['No such user or password']
  15.                 context = {'form':form}
  16.                 return render_template('sign-in.html', **context )
  17.  
  18.         else:
  19.             form.username.errors = ['Enter a Username or Email address']
  20.             context = {'form':form}
  21.             return render_template('sign-in.html', **context )
  22.  
  23.         if user.check_password(password):
  24.             login_user(user)
  25.             return render_template( 'close-iframe.html' )
  26.         else:
  27.             form.username.errors = ['No such user or password']
  28.             context = {'form':form}
  29.             return render_template('sign-in.html', **context )
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top