mirror of
https://github.com/casdoor/casdoor.git
synced 2025-05-24 08:20:31 +08:00
Use helmet on login, signup pages.
This commit is contained in:
parent
3065bacad2
commit
785f306c4b
@ -24,15 +24,16 @@ type Application struct {
|
||||
Name string `xorm:"varchar(100) notnull pk" json:"name"`
|
||||
CreatedTime string `xorm:"varchar(100)" json:"createdTime"`
|
||||
|
||||
DisplayName string `xorm:"varchar(100)" json:"displayName"`
|
||||
Logo string `xorm:"varchar(100)" json:"logo"`
|
||||
HomepageUrl string `xorm:"varchar(100)" json:"homepageUrl"`
|
||||
Description string `xorm:"varchar(100)" json:"description"`
|
||||
Organization string `xorm:"varchar(100)" json:"organization"`
|
||||
EnablePassword bool `json:"enablePassword"`
|
||||
EnableSignUp bool `json:"enableSignUp"`
|
||||
Providers []string `xorm:"varchar(100)" json:"providers"`
|
||||
ProviderObjs []*Provider `xorm:"-" json:"providerObjs"`
|
||||
DisplayName string `xorm:"varchar(100)" json:"displayName"`
|
||||
Logo string `xorm:"varchar(100)" json:"logo"`
|
||||
HomepageUrl string `xorm:"varchar(100)" json:"homepageUrl"`
|
||||
Description string `xorm:"varchar(100)" json:"description"`
|
||||
Organization string `xorm:"varchar(100)" json:"organization"`
|
||||
EnablePassword bool `json:"enablePassword"`
|
||||
EnableSignUp bool `json:"enableSignUp"`
|
||||
Providers []string `xorm:"varchar(100)" json:"providers"`
|
||||
ProviderObjs []*Provider `xorm:"-" json:"providerObjs"`
|
||||
OrganizationObj *Organization `xorm:"-" json:"organizationObj"`
|
||||
|
||||
ClientId string `xorm:"varchar(100)" json:"clientId"`
|
||||
ClientSecret string `xorm:"varchar(100)" json:"clientSecret"`
|
||||
@ -50,7 +51,7 @@ func GetApplications(owner string) []*Application {
|
||||
return applications
|
||||
}
|
||||
|
||||
func extendApplication(application *Application) {
|
||||
func extendApplicationWithProviders(application *Application) {
|
||||
providers := GetProviders(application.Owner)
|
||||
m := map[string]*Provider{}
|
||||
for _, provider := range providers {
|
||||
@ -65,6 +66,11 @@ func extendApplication(application *Application) {
|
||||
}
|
||||
}
|
||||
|
||||
func extendApplicationWithOrg(application *Application) {
|
||||
organization := getOrganization(application.Owner, application.Organization)
|
||||
application.OrganizationObj = organization
|
||||
}
|
||||
|
||||
func getApplication(owner string, name string) *Application {
|
||||
application := Application{Owner: owner, Name: name}
|
||||
existed, err := adapter.engine.Get(&application)
|
||||
@ -73,7 +79,8 @@ func getApplication(owner string, name string) *Application {
|
||||
}
|
||||
|
||||
if existed {
|
||||
extendApplication(&application)
|
||||
extendApplicationWithProviders(&application)
|
||||
extendApplicationWithOrg(&application)
|
||||
return &application
|
||||
} else {
|
||||
return nil
|
||||
@ -89,7 +96,8 @@ func GetDefaultApplication(owner string) *Application {
|
||||
}
|
||||
|
||||
if existed {
|
||||
extendApplication(&application)
|
||||
extendApplicationWithProviders(&application)
|
||||
extendApplicationWithOrg(&application)
|
||||
return &application
|
||||
} else {
|
||||
return nil
|
||||
@ -104,7 +112,8 @@ func getApplicationByClientId(clientId string) *Application {
|
||||
}
|
||||
|
||||
if existed {
|
||||
extendApplication(&application)
|
||||
extendApplicationWithProviders(&application)
|
||||
extendApplicationWithOrg(&application)
|
||||
return &application
|
||||
} else {
|
||||
return nil
|
||||
|
@ -19,6 +19,7 @@ import "./i18n";
|
||||
import i18next from "i18next";
|
||||
import copy from "copy-to-clipboard";
|
||||
import {authConfig} from "./auth/Auth";
|
||||
import {Helmet} from "react-helmet";
|
||||
|
||||
export let ServerUrl = "";
|
||||
|
||||
@ -210,3 +211,16 @@ export function goToLogin(ths, application) {
|
||||
goToLink(`${application.homepageUrl}/login`);
|
||||
}
|
||||
}
|
||||
|
||||
export function renderHelmet(application) {
|
||||
if (application === undefined || application === null || application.organizationObj === undefined || application.organizationObj === null ||application.organizationObj === "") {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (
|
||||
<Helmet>
|
||||
<title>{application.organizationObj.displayName}</title>
|
||||
<link rel="icon" href={application.organizationObj.favicon} />
|
||||
</Helmet>
|
||||
)
|
||||
}
|
||||
|
@ -25,6 +25,7 @@ import {GithubLoginButton, GoogleLoginButton} from "react-social-login-buttons";
|
||||
import QqLoginButton from "./QqLoginButton";
|
||||
import i18next from "i18next";
|
||||
import {authConfig} from "./Auth";
|
||||
import {Helmet} from "react-helmet";
|
||||
|
||||
class LoginPage extends React.Component {
|
||||
constructor(props) {
|
||||
@ -282,6 +283,9 @@ class LoginPage extends React.Component {
|
||||
<Row>
|
||||
<Col span={24} style={{display: "flex", justifyContent: "center"}}>
|
||||
<div style={{marginTop: "80px", textAlign: "center"}}>
|
||||
{
|
||||
Setting.renderHelmet(application)
|
||||
}
|
||||
{
|
||||
Setting.renderLogo(application)
|
||||
}
|
||||
|
@ -56,6 +56,9 @@ class ResultPage extends React.Component {
|
||||
|
||||
return (
|
||||
<div>
|
||||
{
|
||||
Setting.renderHelmet(application)
|
||||
}
|
||||
<Result
|
||||
status="success"
|
||||
title={i18next.t("signup:Your account has been created!")}
|
||||
|
@ -294,6 +294,9 @@ class SignupPage extends React.Component {
|
||||
<Row>
|
||||
<Col span={24} style={{display: "flex", justifyContent: "center"}} >
|
||||
<div style={{marginTop: "10px", textAlign: "center"}}>
|
||||
{
|
||||
Setting.renderHelmet(application)
|
||||
}
|
||||
{
|
||||
Setting.renderLogo(application)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user