FIX debug token

This commit is contained in:
Jasder 2020-08-16 00:54:22 +08:00
parent a9a0cab7d1
commit c40777be2b
3 changed files with 9 additions and 4 deletions

View File

@ -11,6 +11,7 @@ module LoginHelper
def set_autologin_cookie(user)
token = Token.get_or_create_permanent_login_token(user, "autologin")
Rails.logger.info "###### def set_autologin_cookie and get_or_create_permanent_login_token result: #{token&.value}"
cookie_options = {
:value => token.value,
:expires => 1.month.from_now,

View File

@ -10,12 +10,12 @@ class Oauth::EducoderController < Oauth::BaseController
open_user= OpenUsers::Educoder.find_by(uid: login)
if open_user.present? && open_user.user.present? && open_user.user.email_binded?
if current_user != open_user.user
logout_user
successful_authentication(open_user.user)
end
Rails.logger.info "######## open_user exist and open_user.user exsit and email is binded ok"
successful_authentication(open_user.user)
redirect_to callback_url
else
Rails.logger.info "######## open user not exits"
if current_user.blank? || !current_user.logged?
user = User.find_by(login: login)
if user

View File

@ -27,8 +27,10 @@ class Token < ActiveRecord::Base
def self.get_or_create_permanent_login_token(user, type)
token = Token.get_token_from_user(user, type)
Rails.logger.info "###### Token.get_token_from_user result: #{token&.value}"
unless token
token = Token.create(:user => user, :action => type)
Rails.logger.info "###### Token.get_token_from_user is nul and agine create token: #{token&.value}"
else
token.update_attribute(:created_on, Time.now)
end
@ -37,8 +39,10 @@ class Token < ActiveRecord::Base
def self.get_token_from_user(user, action)
token = Token.where(:action => action, :user_id => user).first
Rails.logger.info "###### self.get_token_from_user query result: #{token&.value}"
unless token
token = Token.create!(user_id: user.id, action: action)
Rails.logger.info "###### self.get_token_from_user query is nil and create result: #{token&.value}"
end
token
end