mirror of
https://github.com/astuto/astuto.git
synced 2025-12-16 11:47:56 +01:00
Improvements and fixes on OAuth providers (#304)
This commit is contained in:
committed by
GitHub
parent
32d19cbe7c
commit
39a757fe5b
3
.gitignore
vendored
3
.gitignore
vendored
@@ -10,6 +10,9 @@
|
|||||||
# Ignore vs code config.
|
# Ignore vs code config.
|
||||||
.vscode
|
.vscode
|
||||||
|
|
||||||
|
# Ignore all .DS_Store files.
|
||||||
|
**/.DS_Store
|
||||||
|
|
||||||
# Ignore bundler config.
|
# Ignore bundler config.
|
||||||
/.bundle
|
/.bundle
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ class OAuthsController < ApplicationController
|
|||||||
include HTTParty
|
include HTTParty
|
||||||
include OAuthsHelper
|
include OAuthsHelper
|
||||||
include ApplicationHelper
|
include ApplicationHelper
|
||||||
|
include Devise::Controllers::Rememberable
|
||||||
|
|
||||||
before_action :authenticate_admin, only: [:index, :create, :update, :destroy]
|
before_action :authenticate_admin, only: [:index, :create, :update, :destroy]
|
||||||
|
|
||||||
@@ -124,6 +125,7 @@ class OAuthsController < ApplicationController
|
|||||||
|
|
||||||
if user.oauth_token == params[:token]
|
if user.oauth_token == params[:token]
|
||||||
sign_in user
|
sign_in user
|
||||||
|
remember_me user
|
||||||
user.invalidate_oauth_token
|
user.invalidate_oauth_token
|
||||||
flash[:notice] = I18n.t('devise.sessions.signed_in')
|
flash[:notice] = I18n.t('devise.sessions.signed_in')
|
||||||
redirect_to root_path
|
redirect_to root_path
|
||||||
|
|||||||
@@ -46,9 +46,6 @@ class TenantsController < ApplicationController
|
|||||||
@user.save!
|
@user.save!
|
||||||
|
|
||||||
CreateWelcomeEntitiesWorkflow.new().run
|
CreateWelcomeEntitiesWorkflow.new().run
|
||||||
OAuth.include_only_defaults.each do |o_auth|
|
|
||||||
TenantDefaultOAuth.create(o_auth_id: o_auth.id)
|
|
||||||
end
|
|
||||||
|
|
||||||
logger.info { "New tenant registration: #{Current.tenant.inspect}" }
|
logger.info { "New tenant registration: #{Current.tenant.inspect}" }
|
||||||
|
|
||||||
|
|||||||
@@ -28,7 +28,12 @@ const OAuthProviderItem = ({
|
|||||||
}: Props) => (
|
}: Props) => (
|
||||||
<li className="oAuthListItem">
|
<li className="oAuthListItem">
|
||||||
<div className="oAuthInfo">
|
<div className="oAuthInfo">
|
||||||
|
{
|
||||||
|
oAuth.logo && oAuth.logo.length > 0 ?
|
||||||
<img src={oAuth.logo} className="oAuthLogo" width={42} height={42} />
|
<img src={oAuth.logo} className="oAuthLogo" width={42} height={42} />
|
||||||
|
:
|
||||||
|
<div className="oauthLogo" style={{width: 42, height: 42}}></div>
|
||||||
|
}
|
||||||
|
|
||||||
<div className="oAuthNameAndEnabled">
|
<div className="oAuthNameAndEnabled">
|
||||||
<span className="oAuthName">{oAuth.name}</span>
|
<span className="oAuthName">{oAuth.name}</span>
|
||||||
|
|||||||
@@ -91,7 +91,7 @@ const TenantSignUpP = ({
|
|||||||
if (authMethod == 'oauth') {
|
if (authMethod == 'oauth') {
|
||||||
let redirectUrl = new URL(baseUrl);
|
let redirectUrl = new URL(baseUrl);
|
||||||
redirectUrl.hostname = `${subdomain}.${redirectUrl.hostname}`;
|
redirectUrl.hostname = `${subdomain}.${redirectUrl.hostname}`;
|
||||||
window.location.href = `${redirectUrl.toString()}users/sign_in`;
|
window.location.href = redirectUrl.toString();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ const OAuthProviderLink = ({ oAuthId, oAuthName, oAuthLogo, oAuthReason, isSignU
|
|||||||
onClick={() => window.location.href = `/o_auths/${oAuthId}/start?reason=${oAuthReason}`}
|
onClick={() => window.location.href = `/o_auths/${oAuthId}/start?reason=${oAuthReason}`}
|
||||||
className={`oauthProviderBtn oauthProvider${oAuthName.replace(' ', '')}`}
|
className={`oauthProviderBtn oauthProvider${oAuthName.replace(' ', '')}`}
|
||||||
>
|
>
|
||||||
<img src={oAuthLogo} alt={oAuthName} width={28} height={28} />
|
{ oAuthLogo && oAuthLogo.length > 0 && <img src={oAuthLogo} alt={oAuthName} width={28} height={28} /> }
|
||||||
<span className='oauthProviderText'>
|
<span className='oauthProviderText'>
|
||||||
{
|
{
|
||||||
isSignUp ?
|
isSignUp ?
|
||||||
|
|||||||
@@ -67,5 +67,13 @@ class CreateWelcomeEntitiesWorkflow
|
|||||||
body: 'Users can comment to express their opinions! As with posts and board descriptions, comments can be *Markdown* **formatted**',
|
body: 'Users can comment to express their opinions! As with posts and board descriptions, comments can be *Markdown* **formatted**',
|
||||||
user_id: owner.id
|
user_id: owner.id
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# Set first board as root page
|
||||||
|
TenantSetting.create!(root_board_id: feature_board.id)
|
||||||
|
|
||||||
|
# Enable all default oauths
|
||||||
|
OAuth.include_only_defaults.each do |o_auth|
|
||||||
|
TenantDefaultOAuth.create!(o_auth_id: o_auth.id)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
Reference in New Issue
Block a user