Example #1
0
def addUser(callerPriv):
    '''
    Add a user.
    
    parameters:
    token
    name
    email
    priviledge# Should be more readable
    
    return:
    {results:userid} 
    or
    {"results":{"error":{"code":16,"msg":"Add user fail."}}}
    ...
    '''
    name=request.params.get("name")
    #password=request.params.get("password")
    email=request.params.get("email")
    priviledge=request.params.get("priviledge")
    password=brauth.randomPass(6)

    userId=brauth.addUser(callerPriv=callerPriv,name=name,password=password,email=email,priviledge=priviledge,visible=True)
    if userId==-1:
        return {"results":{"error":{"code":16,"msg":"Add fail."}}}
    else:
        brauth.sendMail(email,name,password)
        return {"results":userId}    
Example #2
0
def addUser(callerPriv):
    '''
    Add a user.
    
    parameters:
    token
    name
    email
    priviledge# Should be more readable
    
    return:
    {results:userid} 
    or
    {"results":{"error":{"code":16,"msg":"Add user fail."}}}
    ...
    '''
    name = request.params.get("name")
    #password=request.params.get("password")
    email = request.params.get("email")
    priviledge = request.params.get("priviledge")
    password = brauth.randomPass(6)

    userId = brauth.addUser(callerPriv=callerPriv,
                            name=name,
                            password=password,
                            email=email,
                            priviledge=priviledge,
                            visible=True)
    if userId == -1:
        return {"results": {"error": {"code": 16, "msg": "Add fail."}}}
    else:
        brauth.sendMail(email, name, password)
        return {"results": userId}
Example #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'}
Example #4
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'}