예제 #1
0
 def post(self):
     # We store the data that we parsed into a Variable
     data = UserLogin.parser.parse_args()
     user = UserModel('', '', data['email'], data['password'])
     try:
         token = user.auth()
         return {
             'success': True,
             'idToken': token['idToken'],
             'refreshToken': token['refreshToken']
         }, 201
     except:
         return {'success': False, 'message': 'Invalid Credentials'}
예제 #2
0
def login_index():
    form = loginForm()

    if request.method == 'POST' and form.validate_on_submit():
        session['login_csrf_token'] = request.form["login_csrf_token"]

        user, authenticated = UserModel.auth(db.session.query, form.email.data,
                                             form.password.data)

        user_id = user.id
        if user_id == None:
            logMsg = "in login execution: user_id is %s."
            logger.warning(logMsg, user)
            return render_template("auth/login.html", form=form)

        if authenticated:
            login_user(user)
            return redirect(url_for('.index'))
        else:
            return render_template("auth/login.html", form=form)
    else:
        return render_template("auth/login.html", form=form)