Last active
August 29, 2015 14:07
-
-
Save MichaelCPell/3169eeb2b119b8b3175a to your computer and use it in GitHub Desktop.
Devise Api::SessionsController
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
class Api::SessionsController < ApiController | |
def create | |
if params[:username] | |
@user = User.find_by_username(params[:username]) | |
token.user = @user if _provided_valid_password? || _provided_valid_api_key? | |
end | |
respond_with token | |
end | |
private | |
def _provided_valid_password? | |
@user.valid_password?(params[:password]) | |
end | |
def _provided_valid_api_key? | |
params[:api_key] == 'foo key' | |
end | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment