示例#1
0
文件: user.py 项目: ljxia/shiftserver
 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())
示例#2
0
文件: user.py 项目: ljxia/shiftserver
    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)