Exemple #1
0
 def read(self, userName):
     if not user.read(userName):
         return error("User %s does not exist" % userName, UserDoesNotExistError)
     loggedInUser = helper.getLoggedInUser()
     if loggedInUser and user.canReadFull(user.idForName(userName),
                                          loggedInUser["_id"]):
         return data(user.readFull(userName).copy())
     else:
         return data(user.read(userName).copy())
Exemple #2
0
    def login(self, userName, password):
        loggedInUser = helper.getLoggedInUser()
        if not loggedInUser:
            theUser = user.readFull(userName)

            if not theUser:
                return error("Invalid user name.", InvalidUserNameError)

            if theUser and (theUser['password'] == md5hash(password)):
                helper.setLoggedInUser(theUser)
                user.updateLastSeen(userName)
                return data(theUser)
            else:
                return error("Incorrect password.", IncorrectPasswordError)
        else:
            return error("Already logged in.", AlreadyLoggedInError)