def post(self): form = request.form un = form['username'] pw = form['password'] nex = form.get('next', url_for("dashboard.index")) logging.info("Next: {}".format(nex)) if not config.LDAP_LOGIN: a = Admin.find_one({'email': un}) if a and a.verify_pwd(pw): login_user(a) logging.info("logged in") return redirect(nex) else: flash("Please try again", "danger") else: try: user = ldap_login(un, pw) a = Admin.find_one({'email': user.get('mail')[0]}) if not a: a = Admin() a.name = user.get('displayName')[0] a.email = user.get('mail')[0] a.last_login = datetime.utcnow() a.save() rem = False if form.get("remember-me"): rem = True success = login_user(a, remember=rem) return redirect(nex) except Exception as e: logging.exception(e) flash("Please try again", "danger") return render_template("auth/login.html", form=form)
def post(self): form = request.form un = form['username'] pw = form['password'] nex = form.get('next', url_for("dashboard.index")) logging.info("Next: {}".format(nex)) if not config.LDAP_LOGIN: a = Admin.find_one({'email':un}) if a and a.verify_pwd(pw): login_user(a) logging.info("logged in") return redirect(nex) else: flash("Please try again", "danger") else: try: user = ldap_login(un, pw) a = Admin.find_one({'email':user.get('mail')[0]}) if not a: a = Admin() a.name = user.get('displayName')[0] a.email = user.get('mail')[0] a.last_login = datetime.utcnow() a.save() rem = False if form.get("remember-me"): rem = True success = login_user(a, remember=rem) return redirect(nex) except Exception as e: logging.exception(e) flash("Please try again", "danger") return render_template("auth/login.html", form=form)
def post(self): form = request.form pwd = form['password'] cpwd = form['confirm_password'] if not Admin.passwords_match(pwd, cpwd): flash("Passwords do not match", "danger") return render_template("auth/register.html", form=form) try: a = Admin() a.name = form['name'] a.email = form['email'] a.password = form['password'] a.save() except DuplicateKeyError as e: logging.exception(e) flash("Email address already taken", "danger") return render_template("auth/register.html", form=form) login_user(a) return redirect(url_for("dashboard.index"))
def post(self): form = request.form pwd = form['password'] cpwd = form['confirm_password'] if not Admin.passwords_match(pwd, cpwd): flash("Passwords do not match", "danger") return render_template("auth/register.html", form=form) try: a = Admin() a.name = form['name'] a.email = form['email'] a.password = form['password'] a.save() except DuplicateKeyError as e: logging.exception(e) flash("Email address already taken", "danger"); return render_template("auth/register.html", form=form) login_user(a) return redirect(url_for("dashboard.index"))