Beispiel #1
0
def __check_login(_username, _password):
    """
    summary:
        Check username and password
    """
    _state = {"success": True, "message": "none", "userid": -1, "realname": ""}
    try:
        _user = User.objects.get(username=_username)

        # To decide password
        if _user.password == function.md5_encode(_password):
            _state["success"] = True
            _state["userid"] = _user.id
            _state["realname"] = _user.realname
        else:
            # Password incorrect
            _state["success"] = False
            _state["message"] = u"密码不正确."
    except User.DoesNotExist:
        # User not exist
        _state["success"] = False
        _state["message"] = u"用户不存在."
    return _state
Beispiel #2
0
 def save(self, modify_pwd=True):
     if modify_pwd:
         self.password = function.md5_encode(self.password)
     self.about = formatter.substr(self.about, 20, True)
     super(User, self).save()