예제 #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)