Ejemplo n.º 1
0
        public static ServerResponse loginUser(string email, string password)
        {
            long id = SqliteHandler.getUserId(email);

            if (id == -1)
            {
                //return a failure with an error message an no payload
                return(new ServerResponse(false, "email doesn't exist", null));
            }
            string realPassword = SqliteHandler.getUserPassword(id);

            //hash password
            password = hashPassword(password);

            if (realPassword != null && realPassword.Equals(password))
            {
                UserModel user = SqliteHandler.getUser(id);
                return(new ServerResponse(true, "user login successfull", user));
            }
            //if not successful
            else
            {
                //...
                //sql call returns no match
                return(new ServerResponse(false, "password doesn't match", null));
            }
        }