mirror of
https://github.com/casdoor/casdoor.git
synced 2025-05-24 08:20:31 +08:00
fix: forget password and sign up router (#1227)
* fix: forget password and sign up router * fix: link * fix: jump logic * fix: signup link * fix: signup link * fix: login and signup router * remove comments * fix: normal router * fix: link abstraction * rename jump component * fix: session storage * fix: store signin url * fix: jumplink props * fix: simplify link * fix: path join * fix: remove unused functions
This commit is contained in:
parent
b0f572c51a
commit
304643736b
@ -70,6 +70,7 @@
|
|||||||
"eslint-plugin-react": "^7.31.1",
|
"eslint-plugin-react": "^7.31.1",
|
||||||
"husky": "^4.3.8",
|
"husky": "^4.3.8",
|
||||||
"lint-staged": "^13.0.3",
|
"lint-staged": "^13.0.3",
|
||||||
|
"path-browserify": "^1.0.1",
|
||||||
"stylelint": "^14.11.0",
|
"stylelint": "^14.11.0",
|
||||||
"stylelint-config-recommended-less": "^1.0.4",
|
"stylelint-config-recommended-less": "^1.0.4",
|
||||||
"stylelint-config-standard": "^28.0.0"
|
"stylelint-config-standard": "^28.0.0"
|
||||||
|
@ -22,6 +22,8 @@ import copy from "copy-to-clipboard";
|
|||||||
import {authConfig} from "./auth/Auth";
|
import {authConfig} from "./auth/Auth";
|
||||||
import {Helmet} from "react-helmet";
|
import {Helmet} from "react-helmet";
|
||||||
import * as Conf from "./Conf";
|
import * as Conf from "./Conf";
|
||||||
|
import {Link} from "react-router-dom";
|
||||||
|
import * as path from "path-browserify";
|
||||||
|
|
||||||
export const ServerUrl = "";
|
export const ServerUrl = "";
|
||||||
|
|
||||||
@ -752,49 +754,64 @@ export function goToLogin(ths, application) {
|
|||||||
goToLinkSoft(ths, "/login");
|
goToLinkSoft(ths, "/login");
|
||||||
} else {
|
} else {
|
||||||
if (application.signinUrl === "") {
|
if (application.signinUrl === "") {
|
||||||
goToLink(`${application.homepageUrl}/login`);
|
goToLink(path.join(application.homepageUrl, "login"));
|
||||||
} else {
|
} else {
|
||||||
goToLink(application.signinUrl);
|
goToLink(application.signinUrl);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function goToSignup(ths, application) {
|
function JumpLink({url, children, onClick}) {
|
||||||
if (application === null) {
|
if (url === null) {
|
||||||
return;
|
return <Link style={{float: "right"}} onClick={onClick} to={""}>{children}</Link>;
|
||||||
}
|
}
|
||||||
|
if (url.startsWith("/")) {
|
||||||
if (!application.enablePassword && window.location.pathname.includes("/login/oauth/authorize")) {
|
return <Link to={url} style={{float: "right"}} onClick={onClick}>{children}</Link>;
|
||||||
const link = window.location.href.replace("/login/oauth/authorize", "/auto-signup/oauth/authorize");
|
} else if (url.startsWith("http")) {
|
||||||
goToLink(link);
|
return <a href={url} target="_blank" rel="noopener noreferrer" style={{float: "right"}} onClick={onClick}>{children}</a>;
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (authConfig.appName === application.name) {
|
|
||||||
goToLinkSoft(ths, "/signup");
|
|
||||||
} else {
|
} else {
|
||||||
if (application.signupUrl === "") {
|
return <Link style={{float: "right"}} onClick={onClick} to={""}>{children}</Link>;
|
||||||
goToLinkSoft(ths, `/signup/${application.name}`);
|
|
||||||
} else {
|
|
||||||
goToLink(application.signupUrl);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function goToForget(ths, application) {
|
function storeSigninUrl() {
|
||||||
if (application === null) {
|
sessionStorage.setItem("signinUrl", window.location.href);
|
||||||
return;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (authConfig.appName === application.name) {
|
export function renderSignupLink(application, text) {
|
||||||
goToLinkSoft(ths, "/forget");
|
let link;
|
||||||
|
|
||||||
|
if (application === null) {
|
||||||
|
link = null;
|
||||||
|
} else if (!application.enablePassword && window.location.pathname.includes("/login/oauth/authorize")) {
|
||||||
|
link = window.location.href.replace("/login/oauth/authorize", "/auto-signup/oauth/authorize");
|
||||||
|
} else if (authConfig.appName === application.name) {
|
||||||
|
link = "/signup";
|
||||||
} else {
|
} else {
|
||||||
if (application.forgetUrl === "") {
|
if (application.signupUrl === "") {
|
||||||
goToLinkSoft(ths, `/forget/${application.name}`);
|
link = `/signup/${application.name}`;
|
||||||
} else {
|
} else {
|
||||||
goToLink(application.forgetUrl);
|
link = application.signupUrl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return <JumpLink url={link} onClick={storeSigninUrl}>{text}</JumpLink>;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function renderForgetLink(application, text) {
|
||||||
|
let link;
|
||||||
|
if (application === null) {
|
||||||
|
link = null;
|
||||||
|
} else if (authConfig.appName === application.name) {
|
||||||
|
link = "/forget";
|
||||||
|
} else {
|
||||||
|
if (application.forgetUrl === "") {
|
||||||
|
link = `/forget/${application.name}`;
|
||||||
|
} else {
|
||||||
|
link = application.forgetUrl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return <JumpLink url={link}>{text}</JumpLink>;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function renderHelmet(application) {
|
export function renderHelmet(application) {
|
||||||
|
@ -405,11 +405,9 @@ class LoginPage extends React.Component {
|
|||||||
{i18next.t("login:Auto sign in")}
|
{i18next.t("login:Auto sign in")}
|
||||||
</Checkbox>
|
</Checkbox>
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
<a style={{float: "right"}} onClick={() => {
|
{
|
||||||
Setting.goToForget(this, application);
|
Setting.renderForgetLink(application, i18next.t("login:Forgot password?"))
|
||||||
}}>
|
}
|
||||||
{i18next.t("login:Forgot password?")}
|
|
||||||
</a>
|
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
<Form.Item>
|
<Form.Item>
|
||||||
<Button
|
<Button
|
||||||
@ -485,12 +483,9 @@ class LoginPage extends React.Component {
|
|||||||
!application.enableSignUp ? null : (
|
!application.enableSignUp ? null : (
|
||||||
<>
|
<>
|
||||||
{i18next.t("login:No account?")}
|
{i18next.t("login:No account?")}
|
||||||
<a onClick={() => {
|
{
|
||||||
sessionStorage.setItem("signinUrl", window.location.href);
|
Setting.renderSignupLink(application, i18next.t("login:sign up now"))
|
||||||
Setting.goToSignup(this, application);
|
}
|
||||||
}}>
|
|
||||||
{i18next.t("login:sign up now")}
|
|
||||||
</a>
|
|
||||||
</>
|
</>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -7918,6 +7918,11 @@ pascal-case@^3.1.2:
|
|||||||
no-case "^3.0.4"
|
no-case "^3.0.4"
|
||||||
tslib "^2.0.3"
|
tslib "^2.0.3"
|
||||||
|
|
||||||
|
path-browserify@^1.0.1:
|
||||||
|
version "1.0.1"
|
||||||
|
resolved "https://registry.yarnpkg.com/path-browserify/-/path-browserify-1.0.1.tgz#d98454a9c3753d5790860f16f68867b9e46be1fd"
|
||||||
|
integrity sha512-b7uo2UCUOYZcnF/3ID0lulOJi/bafxa1xPe7ZPsammBSpjSWQkjNxlt635YGS2MiR9GjvuXCtz2emr3jbsz98g==
|
||||||
|
|
||||||
path-exists@^3.0.0:
|
path-exists@^3.0.0:
|
||||||
version "3.0.0"
|
version "3.0.0"
|
||||||
resolved "https://registry.yarnpkg.com/path-exists/-/path-exists-3.0.0.tgz#ce0ebeaa5f78cb18925ea7d810d7b59b010fd515"
|
resolved "https://registry.yarnpkg.com/path-exists/-/path-exists-3.0.0.tgz#ce0ebeaa5f78cb18925ea7d810d7b59b010fd515"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user