Пример #1
0
def performAddPlatformUser():
    from Utility.EncryptUtil import EncryptUtil
    flag, res = core.PlatformUserAdd(
        session['SID'], request.form['f_username'],
        EncryptUtil.EncryptSHA256(request.form['f_nPassword']),
        1 if request.form['f_level'] == u"管理员" else 0)
    if (flag & res) is False:
        return redirect(url_for('AccessErrorPage', dt='add'))
    return redirect(url_for('userManagement'))
Пример #2
0
 def Auth(username, rawPassword):
     """
     Get authorization token by username and password
     :param username: unique username string, in pattern of username@domain
     :param rawPassword: password without encryption
     :return:
     """
     retVal = SessionManager.Login(username,
                                   EncryptUtil.EncryptSHA256(rawPassword))
     return retVal is not None, retVal
Пример #3
0
def performEditPlatformUser():
    pwd = None
    if request.form['f_nPassword'] != "":
        from Utility.EncryptUtil import EncryptUtil
        pwd = EncryptUtil.EncryptSHA256(request.form['f_nPassword'])
    flag, res = core.PlatformUserUpdate(
        session['SID'], request.form['h_username'], pwd,
        1 if request.form['f_level'] == u"管理员" else 0)
    if flag is False:
        return redirect(url_for('AccessErrorPage', dt='x'))
    return redirect(url_for('userManagement'))
Пример #4
0
 def Connect(**argd):
     """
     Restful API for authority connection.
     :param argd: request argument dictionary
     :return: dumped json string
     """
     flag, ret = CController.CController.Connect(
         argd["username"], EncryptUtil.EncryptSHA256(argd["password"]))
     if flag is False:
         return CGateway._ExceptionResponse()
     if ret is None:
         return CGateway._FailureResponse(
             {"return": "invalid user id or password"})
     return CGateway._SuccessResponse({"session": ret})
Пример #5
0
def performLogin():
    if request.method == 'GET':
        return redirect(url_for('Login'))
    usrId = request.form["passedUserId"]
    usrPwd = request.form["passedUserPwd"]
    import re
    if re.match('^[A-Za-z0-9@.]+$', usrId) is None:
        return redirect(url_for('Login2'))
    from Utility.EncryptUtil import EncryptUtil
    usrPwd = EncryptUtil.EncryptSHA256(usrPwd)
    flag, ret = core.Connect(usrId, usrPwd)
    if flag is False or ret is None:
        return redirect(url_for('Login2'))
    session['AuID'] = usrId
    session['SID'] = ret
    session['AuType'] = 1 if core.AmIAdmin(ret)[1] is True else 0
    return redirect(url_for('home'))