from flask import g
from flask_httpauth import HTTPBasicAuth, HTTPTokenAuth
from app.models import User, UserRole
from app.api.errors import error_response

basic_auth = HTTPBasicAuth()
token_auth = HTTPTokenAuth()

@basic_auth.verify_password
def verify_password(username, password):
  user = User.query.filter_by(username=username).first()
  current_user_role_id = user.role_id
  regular_user_role_id = UserRole.query.filter_by(role_name='regular').first().id
  if current_user_role_id == regular_user_role_id:
    return False
  if user is None:
    return False
  g.current_user = user
  return user.check_password(password)

@token_auth.verify_token
def verify_token(token):
  g.current_user = User.check_token(token) if token else None
  g.current_user = User.check_none_regular_user(token) if token else None
  return g.current_user is not None

@basic_auth.error_handler
def basic_auth_error():
  return error_response(401)
