def Adminlogin(): query = ('SELECT * from notify;') cursor.execute(query) notification = cursor.fetchall() form = AdminLogin() if form.validate_on_submit(): query = ('SELECT Admin_ID, password FROM adminlogin WHERE Admin_ID="' + form.adminID.data + '";') cursor.execute(query) result = cursor.fetchall() print(query) if result: if result[0][1] == form.password.data: #flash('Welcome user!', 'success') #return accounthome(form.passengerID.data) return redirect(url_for('adminhome', adminID=form.adminID.data)) else: flash('Incorrect Password!', 'danger') else: flash('This admin is not registered!', 'danger') return render_template('adminlogin.html', form=form, title="Admin Login", notification=notification)
def admin(): form = AdminLogin() if form.validate_on_submit(): user = Admin.query.filter_by(email=form.email.data).first() if user.password == form.password.data: return redirect(url_for('admin_home')) return render_template('admin_login.html', form=form, title = 'PyraSpace | Admin')
def admin(): subtitle = "Login for administrative tasks" form = AdminLogin(request.form) if form.validate(): if form.password.data == keys.admin_password: session["timestamp"] = datetime.now() return redirect("/bub/admin/mass-upload") else: flash(error_msg(500)) return render_template("admin_login.html", form=form, _errorNo=500) return render_template("admin_login.html", subtitle=subtitle, form=form)
def admin(): subtitle = "Login for administrative tasks" form = AdminLogin(request.form) if form.validate(): if form.password.data == keys.admin_password: session['timestamp'] = datetime.now() return redirect('/bub/admin/mass-upload') else: flash(error_msg(500)) return render_template('admin_login.html', form=form, _errorNo=500) return render_template('admin_login.html', subtitle=subtitle, form=form)
def admin_login(): """ Provides password field for an admin to log in. Automatically redirected here by Flask-Login. """ form = AdminLogin() if form.validate_on_submit(): admin = Admin.query.first() if admin.verify_password(form.admin_password.data): login_user(admin) return redirect(request.args.get('next') or url_for('admin_panel')) flash('Invalid admin password.') return render_template('admin_login.html', form=form)
def logina(): form = AdminLogin() if form.validate_on_submit(): row = Admin.query.filter_by(admin=form.email_id.data).first() if row.check_password(form.password.data) and row is not None: session['admin'] = row.admin session['iid'] = row.institute_id return redirect(url_for('admindashboard')) else: return 'wrong password or account doesnt exist' return render_template('adminlogin.html', form=form)
def adminlogin(): if current_user.is_authenticated: if current_user.type == 'admin': return redirect(url_for('main.index')) return redirect(url_for('student.studentIndex')) form = AdminLogin() if request.method == 'POST': try: valid = validate_email(form.email.data) email = valid.email except EmailNotValidError as e: flash('Invalid email!', 'danger') return redirect(url_for('main.adminlogin')) admin = User.query.filter_by(email=form.email.data).first() if admin is None: flash('Login failed! Please check username and password.', 'danger') return redirect(url_for('main.adminlogin')) if bcrypt.check_password_hash( admin.password, form.password.data ) and admin.email is not None and admin.type == "admin": print(admin) login_user(admin) next = request.args.get('next') if next is None or not next.startswith('/'): next = url_for('main.index') flash('You have been logged in!', 'success') return redirect(next) else: flash('Login failed! Check email and password agian.', 'danger') return redirect(url_for('main.adminlogin')) return render_template('adminlogin.html', form=form)
def admin_prijava(): adminLogin = AdminLogin() if request.method == 'GET': return render_template('admin-login.html', adminLogin=adminLogin) elif request.method == 'POST': if adminLogin.validate_on_submit(): admin = Admin.query.filter_by(email=adminLogin.email.data).first() #return str(admin) if admin: if check_password_hash(admin.password, adminLogin.password.data): session['admin'] = admin.email flash(f'Dobrodošao Admin!', 'success') return redirect(url_for('home')) else: flash(f'Pogrešan email ili lozinka!', 'danger') return redirect(url_for('admin_prijava')) else: flash(f'Korisnik ne postoji', 'danger') return redirect(url_for('admin_prijava')) elif not adminLogin.validate_on_submit(): flash(f'Nešto ste krivo upisali!', 'danger') return redirect(url_for('admin_prijava'))
def adminpanel(): form = AdminLogin(request.form) if request.method == 'POST' and form.validate_on_submit(): logs = form.getMetaData() return render_template('admin.html',isauth=True, logs=logs) return render_template('admin.html',form=form, isauth=False)
def adminpanel(): form = AdminLogin(request.form) if request.method == 'POST' and form.validate_on_submit(): logs = form.getMetaData() return render_template('admin.html', isauth=True, logs=logs) return render_template('admin.html', form=form, isauth=False)