Пример #1
0
def recover_account():
    mnemonic = app.current_request.json_body.get('mnemonic')
    if not mnemonic:
        return jsonify(message='enter a valid mnemonic', is_recovered=False)
    table = dynamodb.Table(Config.identity_dydb_table)
    allItems = dynamoDb.get_all_data(table)
    for item in allItems:
        if item.get('mnemonic') == mnemonic:
            return jsonify(message='account found', uuid=item.get('uuid'))
    return jsonify(message='Invalid mnemonic')
Пример #2
0
 def decorated_function(*args, **kwargs):
     argData = BluePrintRegister.bluePrintIns.current_request.headers.get(
         'authorization')
     if not argData or not " " in argData:
         return jsonify(message='missing authentication token')
     jwtToken = argData.split(' ')[1]
     print(jwtToken)
     if not Authenticator.is_token_valid(jwtToken):
         return jsonify(message='invalid authentication token')
     return f(*args, **kwargs)
Пример #3
0
def get_token():
    username = app.current_request.json_body.get('username')
    password = app.current_request.json_body.get('password')
    confirm = app.current_request.json_body.get('confirm')
    dydbTableObj = dynamodb.Table(Config.service_user_holder_table)
    resp = dydbTableObj.get_item(Key={'username': username})
    try:
        Item = resp.get('Item')
        if not Item.get('password') == password or not Item.get(
                'confirm') == confirm:
            return jsonify(message='Invalid password/confirm', is_token=False)
        if not Item.get('is_active'):
            return jsonify(message='Inactive username', is_token=False)
    except:
        return jsonify(message='Invalid username', is_token=False)
    jwtToken = (Authenticator.create_token(username)).decode('utf-8')
    return jsonify(jwt_token=jwtToken, is_token=True)
Пример #4
0
def get_address():
    mnemonic, address, colab, uuid, walletId, walletKey, walletSecret = Address.generate_the_base(
    )
    print('aniket')
    print(walletId)
    data_for_identity = {
        'mnemonic': mnemonic,
        'address': address,
        'colab': colab,
        'uuid': uuid,
        'walletId': walletId
    }
    dynamoDb.put_data(data=data_for_identity)
    data_for_wallet = {
        'walletId': walletId,
        'walletKey': walletKey,
        'walletSecret': walletSecret,
        'walletBalance': 0
    }
    dynamoDb.put_data_to_wallet(data=data_for_wallet)
    return jsonify(mnemonic=Address.mnemonic,
                   address=Address.address,
                   colab=Address.colab,
                   uuid=Address.uuid)