Class: Auth::Sentry
- Inherits:
-
Object
- Object
- Auth::Sentry
- Defined in:
- lib/auth/sentry.rb
Defined Under Namespace
Classes: User
Instance Method Summary collapse
- #authenticate!(domain = :default) ⇒ Object
-
#initialize(request) ⇒ Sentry
constructor
A new instance of Sentry.
- #user(domain = :default) ⇒ Object
Constructor Details
#initialize(request) ⇒ Sentry
Returns a new instance of Sentry.
8 9 10 |
# File 'lib/auth/sentry.rb', line 8 def initialize(request) @request = request end |
Instance Method Details
#authenticate!(domain = :default) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/auth/sentry.rb', line 12 def authenticate!(domain=:default) case domain.to_sym when :client @client = Auth.authenticate_client(@request.params['client_id'], @request.params['client_secret']) unless @client raise UnauthorizedClient, 'Invalid client' end else if Auth.authenticate_account(@request.params['username'], @request.params['password']) @user = User.new(@request.params['username']) else raise AccessDenied, 'Invalid username or password' end end end |
#user(domain = :default) ⇒ Object
28 29 30 31 32 33 34 35 |
# File 'lib/auth/sentry.rb', line 28 def user(domain=:default) case domain.to_sym when :client @client ? @client : nil else @user ? @user : nil end end |