def index(self): form = LoginForm(request.form) if form.validate_on_submit(): print("login") return render_template("login.html", form=form)
def login(): form = LoginForm() if 'username' in session: username = session['username'] return 'Logged in as ' + username + '<br>' + "<b><a href = '/logout'>click here to log out</a></b>" if request.method == 'POST': username = request.form['username'] password = request.form['password'] login_success = User.authenticate_user(username, password) if login_success: # Successful login session['username'] = username session['password'] = password user_obj = User.get_user(username) session['name'] = user_obj.name return redirect(url_for('index')) else: # Failed login unsuccessful = 'Please check your credentials' return render_template('login.html', title='Sign In', form=form, alertmessage=unsuccessful) if form.validate_on_submit(): flash('Login requested for user {}, remember_me={}'.format( form.username.data, form.remember_me.data)) return redirect('/index') return render_template('login.html', title='Sign In', form=form)
def login(): if current_user.is_authenticated: return redirect(url_for('home')) form = LoginForm() if form.validate_on_submit(): user = Admin.query.filter_by(name=form.username.data).first() if user is None or not user.check_password(form.password.data): flash('Invalid username or password') return redirect(url_for('login')) login_user(user, remember=form.remember_me.data) return redirect(url_for('home')) return render_template('login_template.html', title='Sign In', form=form)
def redirectDbAdmin(db_id): if len(db_id) == 0: flash('[db_id]パラメータを入れてください') return render_template('error/404.html') # データベースオブジェクトを取得する current_db = app.lib.cms_lib.session.get_current_db(db_id) # グローバル変数に設定する app.lib.cms_lib.session.current_db = current_db if current_db is None: flash('[db_id:{}]情報を取得できません'.format(db_id)) return render_template('error/404.html') StrUtil.print_debug("db_adm_login_required. cur_db.db_id=[{}]".format( str(current_db.db_id))) if current_user.is_active: session['last_login_user_id'] = current_user.get_id() return set_cookie( StrUtil.get_safe_config(current_app, 'CMS_DB_SYS_COOKIE'), current_user.tuid, url_for('db_adm_index', db_id=db_id)) form = LoginForm() # ログイン情報を保持する last_login_user_id = StrUtil.get_safe_edit_mode('last_login_user_id', session) user_id = request.args.get('user_id') or last_login_user_id if user_id: form.user_id.data = user_id return render_template('cms_admin/login.html', form=form, db_id=db_id, db_name=current_db.db_name, systemVersion="Developer Version 1.00")
def login(): form = LoginForm() if g.user.is_authenticated(): return redirect(url_for('index')) if form.validate_on_submit(): username = form.login.data user = User.query.filter_by(username=username).first() if sessions.validate_login(username, form.password.data): sessions.start_session(username) login_user(user) userdata = UserDataDB.query.filter_by(username=user.username).first() flash("Logged in successfully.") # Tell Flask-Principal the identity changed identity_changed.send(current_app._get_current_object(), identity=Identity(user.id)) return redirect(request.args.get('next') or url_for('user.show_user_page', _id=userdata.id)) return render_template('login.jinja2.html', form=form)
def login(): form = LoginForm() if form.validate_on_submit() and request.method == 'POST': email = form.email.data password = form.password.data user = User.query.filter_by(email=email).first() if user and user.verify_password(password): login_user(user) flash('Logged in successfully.') next = request.args.get('next') if not is_safe_url(next): return abort(400) return redirect(next or url_for('routes.home')) else: flash('Invalid Email and/or password.') return render_template('login.html', form=form) else: return render_template('login.html', form=form)
def login(): form = LoginForm() if current_user.is_authenticated: next = request.args.get('next') return redirect(next or url_for('index')) if form.validate_on_submit(): name = form.name.data password = form.password.data form.name.data = '' form.password.data = '' user = User.name(name) print(user) if user is not None and user.password == password: login_user(user) next = request.args.get('next') return redirect(next or url_for('index')) else: return render_template('login.html', form=form, error=True) return render_template('login.html', form=form)
def login(): # if current_user.is_authenticated: # return redirect(url_for('index')) form = LoginForm() return doLogin(get_db_id(), form)
def login(): form = LoginForm() return doAdminLogin(form)
def login(): form = LoginForm() return doDbAdminLogin(get_db_id(), form)