def post(self): username = self.get_argument('username', None) password = self.get_argument('password', None) print 'self.request = ', self.request print 'username = '******'password = '******'U = ', U if not U: return self.write_fail(_('No such user.')) if U: if U.is_locked: return self.write_fail(_('User is locked')) if not check_login_passwd(password, U.password): return self.write_fail(_('Password is wrong.')) session_key = self.save_session(U.id) U.last_login = datetime.datetime.now() self.db.commit() self.write_success(_('Welcome to LYC.'), session_key=session_key)
def post(self): username = self.get_argument('username', None) password = self.get_argument('password', None) print 'self.request = ', self.request print 'username = '******'password = '******'U = ', U if not U: return self.write_fail( _('No such user.') ) if U: if U.is_locked: return self.write_fail( _('User is locked') ) if not check_login_passwd( password, U.password ): return self.write_fail( _('Password is wrong.') ) session_key = self.save_session( U.id ) U.last_login = datetime.datetime.now() self.db.commit() self.write_success( _('Welcome to LYC.'), session_key = session_key )
def validate_password(form, field): if '@' in form.user.data: user = form._handler.db.query(User).filter_by( email=form.user.data).first() else: user = form._handler.db.query(User).filter_by( username=form.user.data).first() if user: if not check_login_passwd(field.data, user.password): raise ValidationError(_('Password is wrong.'))
def validate_password(form, field): if '@' in form.user.data: user = form._handler.db.query(User).filter_by( email = form.user.data ).first() else: user = form._handler.db.query(User).filter_by( username = form.user.data ).first() if user: if not check_login_passwd( field.data, user.password ): raise ValidationError( _('Password is wrong.') )