Created
June 27, 2014 09:39
-
-
Save waaadim/62b9f899ecc14dd72f66 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class SessionsController < Devise::SessionsController | |
# skip_before_filter :require_no_authentication | |
def create | |
# raise user_signed_in?.inspect | |
self.resource = warden.authenticate!(auth_options) | |
set_flash_message(:notice, :signed_in) if is_flashing_format? | |
resource.authentication_token = nil | |
resource.save! | |
sign_in(resource_name, resource) | |
yield resource if block_given? | |
data = { id: resource.id, nickname: resource.nickname, email: resource.email, token: resource.authentication_token } | |
render_response({status: 'success', data: data }) | |
end | |
def destroy | |
# TODO: regenerate token | |
super | |
end | |
protected | |
def auth_options | |
{ scope: resource_name, recall: "#{controller_path}#new" } | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment