Exemple #1
0
    def post(self):
        if 'user' in session:
            return '', 400

        args = parser.parse_args()

        credentials = Authentication.get_credentials(args['Authorization'])
        is_authenticated = Authentication.authenticate_user(credentials)

        if is_authenticated:
            session['user'] = credentials['username']

            return '', 200
        else:
            return '', 401
Exemple #2
0
    def post(self):
        args = parser.parse_args()

        credentials = Authentication.get_credentials(args['Authorization'])

        user_exists = check_if_user_exists(credentials['username'])
        if user_exists:
            return '', 409

        hash = pbkdf2_sha256.encrypt(credentials['password'],
                                     rounds=100,
                                     salt_size=16)

        register_new_user(credentials['username'], hash)

        return '', 200