Update oauth2 url.

This commit is contained in:
BoHung Chiu 2021-10-08 17:19:47 +08:00
parent f2b9c159ca
commit 1311d8fd66
1 changed files with 3 additions and 3 deletions

View File

@ -3,13 +3,13 @@ class SsoLoginBoxController < SessionsController
OpenSSL::SSL::VERIFY_PEER = OpenSSL::SSL::VERIFY_NONE
def oauth2_auth_page
session[:referer_url] = params[:referer_url]
redirect_to "https://nu04.ccu.edu.tw/oauth2.0/authorize?response_type=#{ENV['RESPONSE_TYPE']}&client_id=#{ENV['APP_ID']}&redirect_uri=#{ENV['REDIRECT_URI']}"
redirect_to "https://cas.ccu.edu.tw/oauth2.0/authorize?response_type=#{ENV['RESPONSE_TYPE']}&client_id=#{ENV['APP_ID']}&redirect_uri=#{ENV['REDIRECT_URI']}"
end
def oauth2_sign_in
# receive code from ntnu
code = params[:code]
# request token by code
token_connection = Faraday.new 'https://nu04.ccu.edu.tw/oauth2.0/accessToken'
token_connection = Faraday.new 'https://cas.ccu.edu.tw/oauth2.0/accessToken'
token_response = token_connection.post do |request|
request.params['grant_type'] = 'authorization_code'
request.params['client_id'] = ENV['APP_ID']
@ -22,7 +22,7 @@ class SsoLoginBoxController < SessionsController
# render :html => {:code => code,:token => token, :response => token_response.body}
# request user id by token
account_connection = Faraday.new 'https://nu04.ccu.edu.tw/oauth2.0/profile'
account_connection = Faraday.new 'https://cas.ccu.edu.tw/oauth2.0/profile'
account_response = account_connection.get do |request|
request.params['access_token'] = token
end