Change token login to get

This commit is contained in:
benji 2015-10-07 15:06:01 +02:00
parent 88096fc46a
commit 328f806d39
2 changed files with 8 additions and 4 deletions

View file

@ -5,8 +5,12 @@ class WelcomeController < ApplicationController
end
def token_sign_in
return head(:unauthorized) unless params[:token] == Rails.application.secrets.koelkast_token
koelkast = User.find_by(name: "koelkast")
sign_in_and_redirect koelkast
if user_signed_in? || params[:token] == Rails.application.secrets.koelkast_token
redirect_to root_path
return
else
koelkast = User.find_by(name: "koelkast")
sign_in_and_redirect koelkast
end
end
end

View file

@ -3,7 +3,7 @@ Rails.application.routes.draw do
devise_scope :user do
get 'sign_out', to: 'devise/sessions#destroy', as: :destroy_user_session
post 'sign_in', to: 'welcome#token_sign_in'
get 'sign_in', to: 'welcome#token_sign_in'
unauthenticated :user do
root to: 'welcome#index'
end