Created
December 26, 2015 18:16
-
-
Save theotherdon/2034d290b6344d89adba to your computer and use it in GitHub Desktop.
Login a User programatically with ng-token-auth.
This file contains hidden or 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
def login_user_programatically | |
# User or whatever the name of the model is that you're trying to authenticate | |
@request.env['devise.mapping'] = Devise.mappings[:user] | |
@resource = FactoryGirl.create(:confirmed_user) | |
# The following two lines are where the magic happens. | |
@auth_headers = @resource.create_new_auth_token | |
@request.headers.merge!(@auth_headers) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment