Add SignupUrl and ForgetUrl to Application.

This commit is contained in:
Yang Luo 2021-05-03 00:48:02 +08:00
parent 76e4490aa7
commit 813204194f
4 changed files with 65 additions and 13 deletions

View File

@ -39,6 +39,8 @@ type Application struct {
ClientSecret string `xorm:"varchar(100)" json:"clientSecret"` ClientSecret string `xorm:"varchar(100)" json:"clientSecret"`
RedirectUris []string `xorm:"varchar(1000)" json:"redirectUris"` RedirectUris []string `xorm:"varchar(1000)" json:"redirectUris"`
ExpireInHours int `json:"expireInHours"` ExpireInHours int `json:"expireInHours"`
SignupUrl string `xorm:"varchar(100)" json:"signupUrl"`
ForgetUrl string `xorm:"varchar(100)" json:"forgetUrl"`
} }
func GetApplications(owner string) []*Application { func GetApplications(owner string) []*Application {

View File

@ -236,6 +236,26 @@ class ApplicationEditPage extends React.Component {
}} /> }} />
</Col> </Col>
</Row> </Row>
<Row style={{marginTop: '20px'}} >
<Col style={{marginTop: '5px'}} span={2}>
{i18next.t("general:Signup URL")}:
</Col>
<Col span={22} >
<Input prefix={<LinkOutlined/>} value={this.state.application.signupUrl} onChange={e => {
this.updateApplicationField('signupUrl', e.target.value);
}} />
</Col>
</Row>
<Row style={{marginTop: '20px'}} >
<Col style={{marginTop: '5px'}} span={2}>
{i18next.t("general:Forget URL")}:
</Col>
<Col span={22} >
<Input prefix={<LinkOutlined/>} value={this.state.application.forgetUrl} onChange={e => {
this.updateApplicationField('forgetUrl', e.target.value);
}} />
</Col>
</Row>
<Row style={{marginTop: '20px'}} > <Row style={{marginTop: '20px'}} >
<Col style={{marginTop: '5px'}} span={2}> <Col style={{marginTop: '5px'}} span={2}>
{i18next.t("general:Providers")}: {i18next.t("general:Providers")}:

View File

@ -212,6 +212,38 @@ export function goToLogin(ths, application) {
} }
} }
export function goToSignup(ths, application) {
if (application === null) {
return;
}
if (authConfig.appName === application.name) {
goToLinkSoft(ths, "/signup");
} else {
if (application.signupUrl === "") {
goToLinkSoft(ths, `/signup/${application.name}`);
} else {
goToLink(application.signupUrl);
}
}
}
export function goToForget(ths, application) {
if (application === null) {
return;
}
if (authConfig.appName === application.name) {
goToLinkSoft(ths, "/forget");
} else {
if (application.signupUrl === "") {
goToLinkSoft(ths, `/forget/${application.name}`);
} else {
goToLink(application.forgetUrl);
}
}
}
export function renderHelmet(application) { export function renderHelmet(application) {
if (application === undefined || application === null || application.organizationObj === undefined || application.organizationObj === null ||application.organizationObj === "") { if (application === undefined || application === null || application.organizationObj === undefined || application.organizationObj === null ||application.organizationObj === "") {
return null; return null;

View File

@ -140,14 +140,6 @@ class LoginPage extends React.Component {
} }
} }
getSignupPath(application) {
if (authConfig.appName === application.name) {
return "/signup";
} else {
return `/signup/${application.name}`;
}
}
renderForm(application) { renderForm(application) {
if (this.state.msg !== null) { if (this.state.msg !== null) {
return Util.renderMessage(this.state.msg) return Util.renderMessage(this.state.msg)
@ -203,7 +195,9 @@ class LoginPage extends React.Component {
{i18next.t("login:Auto login")} {i18next.t("login:Auto login")}
</Checkbox> </Checkbox>
</Form.Item> </Form.Item>
<Link style={{float: "right"}} to="/forgot"> <Link style={{float: "right"}} onClick={() => {
Setting.goToForget(this, application);
}}>
{i18next.t("login:Forgot password?")} {i18next.t("login:Forgot password?")}
</Link> </Link>
</Form.Item> </Form.Item>
@ -220,7 +214,9 @@ class LoginPage extends React.Component {
!application.enableSignUp ? null : ( !application.enableSignUp ? null : (
<div style={{float: "right"}}> <div style={{float: "right"}}>
{i18next.t("login:No account yet?")}&nbsp; {i18next.t("login:No account yet?")}&nbsp;
<Link to={this.getSignupPath(application)}> <Link onClick={() => {
Setting.goToSignup(this, application);
}}>
{i18next.t("login:sign up now")} {i18next.t("login:sign up now")}
</Link> </Link>
</div> </div>
@ -259,9 +255,11 @@ class LoginPage extends React.Component {
<div> <div>
<br/> <br/>
<div style={{float: "right"}}> <div style={{float: "right"}}>
No account yet?&nbsp; {i18next.t("login:No account yet?")}&nbsp;
<Link to={this.getSignupPath(application)}> <Link onClick={() => {
sign up now Setting.goToSignup(this, application);
}}>
{i18next.t("login:sign up now")}
</Link> </Link>
</div> </div>
</div> </div>