mirror of
https://github.com/discourse/discourse.git
synced 2024-11-23 06:29:30 +08:00
30990006a9
This reduces chances of errors where consumers of strings mutate inputs and reduces memory usage of the app. Test suite passes now, but there may be some stuff left, so we will run a few sites on a branch prior to merging
44 lines
961 B
Ruby
44 lines
961 B
Ruby
# frozen_string_literal: true
|
|
|
|
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.
|
|
def log_on_user(user, session, cookies, opts = {})
|
|
raise NotImplementedError
|
|
end
|
|
|
|
# optional interface to be called to refresh cookies etc if needed
|
|
def refresh_session(user, session, cookies)
|
|
end
|
|
|
|
# api has special rights return true if api was detected
|
|
def is_api?
|
|
raise NotImplementedError
|
|
end
|
|
|
|
def is_user_api?
|
|
raise NotImplementedError
|
|
end
|
|
|
|
# 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
|