Exemplo n.º 1
0
def userAuthByNamePwd(name,pwd):
    if name is None:
        return error.ERR_CODE_ERR_,None
    row = database.db_select_user_by_name(name)
    if len(row)<=0:
        return error.ERR_CODE_ERR_,None
    if pwd != row[2]:
        return error.ERR_CODE_ERR_,None
    return error.ERR_CODE_OK_,row[0]
Exemplo n.º 2
0
def priv_init():
    """
    some default privilege table will be created in phase of iotx server init.
    0 super user
    1 any role can create a user
    2 any role can access a device(if has accessKey, and login)
    3 ...
    """
    # get super user id , and create topest privilege table
    row = database.db_select_user_by_name(configure.super_user_name)
    if len(row) > 0:
        database.db_insert_privilege("user", row[0], "all", "all", "all", "all")
    database.db_insert_privilege("user", "all", "all", "user", "all", "add")
    database.db_insert_privilege("user", "all", "all", "device", "all", "add")