Created
March 30, 2018 12:59
-
-
Save cosmic-byte/b1a91bcd34f0c3602b3789969aaa82db to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def generate_token(user): | |
| try: | |
| # generate the auth token | |
| auth_token = user.encode_auth_token(user.id) | |
| response_object = { | |
| 'status': 'success', | |
| 'message': 'Successfully registered.', | |
| 'Authorization': auth_token.decode() | |
| } | |
| return response_object, 201 | |
| except Exception as e: | |
| response_object = { | |
| 'status': 'fail', | |
| 'message': 'Some error occurred. Please try again.' | |
| } | |
| return response_object, 401 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment