コード例 #1
0
ファイル: brauth_api.py プロジェクト: liuct/bugquery-lt
def changePassword():
    '''
    User can change their password themselves.

    Parameters:
    Content-Type: application/json
    
    {username:name,oldpass:pass,newpass:pass}
    
    Return:
    {"error":{"code":11,"msg":"Authentication fail"}}
    or:
    {"token":"12345"}
    
    '''
    data=request.json
    username=data["name"]
    oldpass=data["oldpass"]
    newpass=data["newpass"]
    info=brauth.auth(username,oldpass)
    if info==None:
        return {'results':{"error":{"code":11,"msg":"Authentication fail"}}}
    else:
        #print "name:%s,pass:%s"%(username,newpass)
        brauth.setPass(username,newpass)
        #response.set_header("Content-Type","application/json")
        return {'results':'OK'}
コード例 #2
0
def changePassword():
    '''
    User can change their password themselves.

    Parameters:
    Content-Type: application/json
    
    {username:name,oldpass:pass,newpass:pass}
    
    Return:
    {"error":{"code":11,"msg":"Authentication fail"}}
    or:
    {"token":"12345"}
    
    '''
    data = request.json
    username = data["name"]
    oldpass = data["oldpass"]
    newpass = data["newpass"]
    info = brauth.auth(username, oldpass)
    if info == None:
        return {
            'results': {
                "error": {
                    "code": 11,
                    "msg": "Authentication fail"
                }
            }
        }
    else:
        #print "name:%s,pass:%s"%(username,newpass)
        brauth.setPass(username, newpass)
        #response.set_header("Content-Type","application/json")
        return {'results': 'OK'}
コード例 #3
0
def resetPass(callerPriv):
    '''
    Parameters:
    name

    '''
    user = request.params.get("name")
    if user == None:
        return {
            "results": {
                "error": {
                    "code": 13,
                    "msg": "Parameter missing."
                }
            }
        }
    else:
        info = brauth.getUser(name=user)
        if info == None:
            return {
                "results": {
                    "error": {
                        "code": 14,
                        "msg": "Can not find the user."
                    }
                }
            }
        else:
            if callerPriv > info['priviledge']:
                return {
                    "results": {
                        "error": {
                            "code": 15,
                            "msg": "Insufficient right."
                        }
                    }
                }
            else:
                newpass = brauth.randomPass(6)
                brauth.setPass(user, newpass)
                brauth.sendMail(info['email'], user, newpass)
                return {'results': 'OK'}
コード例 #4
0
ファイル: brauth_api.py プロジェクト: liuct/bugquery-lt
def resetPass(callerPriv):
    '''
    Parameters:
    name

    '''
    user=request.params.get("name")
    if user==None:
        return {"results":{"error":{"code":13,"msg":"Parameter missing."}}}
    else:
        info=brauth.getUser(name=user)
        if info==None:
            return {"results":{"error":{"code":14,"msg":"Can not find the user."}}}
        else:
            if callerPriv>info['priviledge']:
                return {"results":{"error":{"code":15,"msg":"Insufficient right."}}}
            else:
                newpass=brauth.randomPass(6)
                brauth.setPass(user,newpass)
                brauth.sendMail(info['email'],user,newpass)
                return {'results':'OK'}