def mutate(root, info, x, email: str): ts = get_token_serializer() new_token = ts.dumps(email, salt='email-confirm-key') confirm_url = f'{urls["webpage"]}/services/account-activation/{new_token}' spcall = f'EXEC sp_refresh_user_activation_token \'{email}\', \'{confirm_url}\'' result = sql_server_call_proc(spcall) return RefreshActivationTokenMutation(result=result)
def mutate(root, info, x, username: str, password: str, email: str): ts = get_token_serializer() token = ts.dumps(email, salt='email-confirm-key') confirm_url = f'{urls["webpage"]}/services/account-activation/{token}' spcall = f'EXEC sp_create_user \'{username}\', \'{password}\', \'{email}\', \'{confirm_url}\'' result = sql_server_call_proc(spcall) return CreateUserMutation(result=result)
def mutate(root, info, _, **kwargs): identity = get_jwt_identity() user_id = identity['userId'] account_name = kwargs['accountName'] init_amount = kwargs['initAmount'] spcall = f'EXEC sp_create_account \'{user_id}\', \'{account_name}\', {init_amount}' result = sql_server_call_proc(spcall) return CreateAccount(result=SPCallResultType(**result))
def mutate(cls, info, _, **kwargs): movDesc = kwargs['movDesc'] amount = kwargs['amount'] accountId = kwargs['accountId'] movTypeId = kwargs['movTypeId'] dateId = kwargs['dateId'] spcall = f'EXEC sp_add_movement \'{movDesc}\', ' \ f'{amount}, ' \ f'\'{accountId}\', ' \ f'\'{movTypeId}\', ' \ f'\'{dateId}\'' result = sql_server_call_proc(spcall) return AddMovement(result=SPCallResultType(**result))
def mutate(cls, _, info, token: str): # Token validation. ts = get_token_serializer() try: email = ts.loads(token, salt="email-confirm-key", max_age=60) # 1 day expiration. spcall = f'EXEC sp_user_activation \'{email}\'' result = sql_server_call_proc(spcall) except itsdangerous.exc.SignatureExpired: result = { 'status': False, 'errorMsg': 'SignatureExpired', } except itsdangerous.exc.BadSignature: result = { 'status': False, 'errorMsg': 'BadSignature', } return UserActivationMutation(result=result)
def mutate(root, info, _, **kwargs): accountId = kwargs['accountId'] spcall = f'EXEC sp_delete_account \'{accountId}\'' result = sql_server_call_proc(spcall) return DeleteAccount(result=SPCallResultType(**result))
def mutate(cls, info, _, **kwargs): movId = kwargs['movId'] spcall = f'EXEC sp_delete_movement \'{movId}\'' result = sql_server_call_proc(spcall) return DeleteMovement(result=SPCallResultType(**result))