2013-10-09 12:10:37 +08:00
|
|
|
module Auth; end
|
|
|
|
class Auth::CurrentUserProvider
|
|
|
|
|
|
|
|
# do all current user initialization here
|
|
|
|
def initialize(env)
|
|
|
|
raise NotImplementedError
|
|
|
|
end
|
|
|
|
|
|
|
|
# our current user, return nil if none is found
|
|
|
|
def current_user
|
|
|
|
raise NotImplementedError
|
|
|
|
end
|
|
|
|
|
|
|
|
# log on a user and set cookies and session etc.
|
2018-11-12 22:34:12 +08:00
|
|
|
def log_on_user(user, session, cookies, opts = {})
|
2013-10-09 12:10:37 +08:00
|
|
|
raise NotImplementedError
|
|
|
|
end
|
|
|
|
|
2016-07-25 10:07:31 +08:00
|
|
|
# optional interface to be called to refresh cookies etc if needed
|
2017-07-28 09:20:09 +08:00
|
|
|
def refresh_session(user, session, cookies)
|
2016-07-25 10:07:31 +08:00
|
|
|
end
|
|
|
|
|
2013-10-09 12:10:37 +08:00
|
|
|
# api has special rights return true if api was detected
|
|
|
|
def is_api?
|
|
|
|
raise NotImplementedError
|
|
|
|
end
|
|
|
|
|
2016-12-16 09:05:20 +08:00
|
|
|
def is_user_api?
|
|
|
|
raise NotImplementedError
|
|
|
|
end
|
|
|
|
|
2013-10-09 12:10:37 +08:00
|
|
|
# we may need to know very early on in the middleware if an auth token
|
|
|
|
# exists, to optimise caching
|
|
|
|
def has_auth_cookie?
|
|
|
|
raise NotImplementedError
|
|
|
|
end
|
|
|
|
|
|
|
|
def log_off_user(session, cookies)
|
|
|
|
raise NotImplementedError
|
|
|
|
end
|
|
|
|
end
|