Example #1
0
    def loginValidate(params):
        try:
            if 'password' not in params:
                username = params['username']
                if not Dbase.usernameExists(username):
                    response = make_response(json.dumps('InValid Username'),
                                             400)
                    response.headers['Content-Type'] = 'application/json'
                    return response
                response = make_response(json.dumps('Valid Username'), 200)
                response.headers['Content-Type'] = 'application/json'
                return response
            else:
                username = params['username']
                password = params['password']
                if not Dbase.verifyLoginPassword(username, password):
                    response = make_response(json.dumps('Invalid Credentials'),
                                             400)
                    response.headers['Content-Type'] = 'application/json'
                    return response

#login successful
                ssn = Dbase.getSecurityNumber(username)
                customername = Dbase.getCustomerName(ssn)
                login_session['ssn'] = ssn
                login_session['customername'] = customername
                login_session['username'] = username
                response = make_response(json.dumps('Valid Credentials'), 200)
                response.headers['Content-Type'] = 'application/json'
                return response
        except Exception as e:
            raise e
Example #2
0
 def username(username):
     if len(username) < 3:
         response = make_response(
             json.dumps('Username must have atleast 3 character'), 400)
         response.headers['Content-Type'] = 'application/json'
         return response
     if Dbase.usernameExists(username):
         response = make_response(json.dumps('Username already taken'), 400)
         response.headers['Content-Type'] = 'application/json'
         return response
     response = make_response(json.dumps('Valid Username'), 200)
     response.headers['Content-Type'] = 'application/json'
     return response