Skip to content

Instantly share code, notes, and snippets.

@DhirajBhakta
Created April 11, 2017 17:04
Show Gist options
  • Select an option

  • Save DhirajBhakta/aa76277322b7cbda5eb373d09b3a4265 to your computer and use it in GitHub Desktop.

Select an option

Save DhirajBhakta/aa76277322b7cbda5eb373d09b3a4265 to your computer and use it in GitHub Desktop.
#patient Login(STUDENT,EMPLOYEE)
@auth.route('/login',methods=['GET','POST'])
def login():
if current_user.is_authenticated:
return redirect(url_for('patient.showPatientProfile'))
form = LoginForm()
if form.validate_on_submit():
cursor = mysql.connect().cursor()
user = USER.checkIfIDExists(cursor,form.ID.data)
if user is not None:
if not user.isConfirmed(cursor):
flash('Email ID not confirmed! Please click on the link given to you via email', 'danger')
return render_template('auth/login.html',form=form)
if user.verify_password(form.password.data):
session['mode']=-1
g.test_msg = "login success"
login_user(user)
utype = user.get_utype()
if(utype=="EMPLOYEE"):
return redirect(url_for('patient.switchUser'))
return redirect(url_for('patient.showPatientProfile'))
else:
g.test_msg = "invalid username or password"
flash('Invalid UserName or Password.')
else:
g.test_msg = "invalid username or password"
flash('Invalid UserName or Password.')
return render_template('auth/login.html',form=form)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment