def validate(self): if not Form.validate(self): return False user_name = self.user_name.data.lower() user_pass = self.user_pass.data.lower() if User.exists(user_name, user_pass): if AddUser.gen_temp_url_key(user_name, user_pass): print 'DEBUG: forms.validate.LoginForm :: gen_temp_url_key : True' return User.get_info(user_name, user_pass) else: self.submit.errors.append("Invalid user name or password !!!") return False
def validate(self): if not Form.validate(self): return False name = self.user_name.data.lower() passwd = self.user_pass.data.lower() if self.user_pass.data != self.confirm_user_pass.data: self.confirm_user_pass.errors.append("Passwords do not match !") return False if User.exists(name, passwd): self.user_name.errors.append("This Username is already taken !") return False email = self.user_email.data.lower() if AddUser.add_user(name, passwd, email): if AddUser.gen_temp_url_key(name, passwd): print 'DEBUG: forms.validate.add_user :: gen_temp_url_key : True' return True else: self.user_email.errors.append("This email is already taken !") return False
def login(): form = LoginForm() if request.method == 'POST': if not form.validate(): return render_template('login.html', title='Login', form=form) else: if User.exists(form.user_name.data.lower(), form.user_pass.data.lower()): ses = User.get_info(form.user_name.data.lower(), form.user_pass.data.lower()) print 'DEBUG: views.login :: ' + ses['StorageURL'], ses['Token'] session['user_name'] = form.user_name.data.lower() session['url'] = ses['StorageURL'] session['token'] = ses['Token'] session['temp_url_key'] = ses['Temp_Url_Key'] session['account'] = ses['Account'] return redirect(url_for('account')) elif request.method == 'GET': if 'url' in session and 'token' in session: return redirect(url_for('account')) else: return render_template('login.html', title='Login', form=form)