Added user/pw auth to api back

This commit is contained in:
Wedge 2016-03-25 14:02:16 +03:00
parent 1f18eca69c
commit b9326ab444
2 changed files with 0 additions and 10 deletions

View File

@ -16,14 +16,6 @@ class Api::V1::BaseController < ApplicationController
protected protected
def check_auth def check_auth
authenticate_or_request_with_http_basic do |token,pw|
if user = User.find_by_authentication_token(token)
sign_in user, false
end
end
end
def check_auth_pw_or_token
authenticate_or_request_with_http_basic do |username,pw| authenticate_or_request_with_http_basic do |username,pw|
if user = User.auth_by_token_or_login_pass(username, pw) if user = User.auth_by_token_or_login_pass(username, pw)
sign_in user, false sign_in user, false

View File

@ -1,8 +1,6 @@
class Api::V1::UsersController < Api::V1::BaseController class Api::V1::UsersController < Api::V1::BaseController
before_action :authenticate_user! before_action :authenticate_user!
before_action :check_auth_pw_or_token, only: :show_current_user
skip_before_action :check_auth, only: :show_current_user
skip_before_action :check_auth, only: [:show] if APP_CONFIG['anonymous_access'] skip_before_action :check_auth, only: [:show] if APP_CONFIG['anonymous_access']
skip_before_action :authenticate_user!, only: [:show] if APP_CONFIG['anonymous_access'] skip_before_action :authenticate_user!, only: [:show] if APP_CONFIG['anonymous_access']
before_action :load_user, only: %i(show) before_action :load_user, only: %i(show)