add current_user_provider so people can override current_user bevior cleanly, see

http://meta.discourse.org/t/amending-current-user-logic-in-discourse/10278
This commit is contained in:
Sam
2013-10-09 15:10:37 +11:00
parent 8e6ae0e278
commit 7993845bfa
15 changed files with 178 additions and 84 deletions

View File

@ -0,0 +1,34 @@
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)
raise NotImplementedError
end
# api has special rights return true if api was detected
def is_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