mirror of
https://github.com/casdoor/casdoor.git
synced 2025-07-20 17:33:49 +08:00
Compare commits
4 Commits
Author | SHA1 | Date | |
---|---|---|---|
a8699d0b87 | |||
6621d693de | |||
dc3131c683 | |||
042a8d0ad6 |
@ -164,7 +164,7 @@ func (c *ApiController) SendVerificationCode() {
|
||||
c.SetSession(MfaDestSession, vform.Dest)
|
||||
}
|
||||
|
||||
provider, err = application.GetEmailProvider()
|
||||
provider, err = application.GetEmailProvider(vform.Method)
|
||||
if err != nil {
|
||||
c.ResponseError(err.Error())
|
||||
return
|
||||
@ -210,7 +210,7 @@ func (c *ApiController) SendVerificationCode() {
|
||||
vform.CountryCode = mfaProps.CountryCode
|
||||
}
|
||||
|
||||
provider, err = application.GetSmsProvider()
|
||||
provider, err = application.GetSmsProvider(vform.Method)
|
||||
if err != nil {
|
||||
c.ResponseError(err.Error())
|
||||
return
|
||||
|
@ -38,12 +38,38 @@ func (application *Application) GetProviderByCategory(category string) (*Provide
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (application *Application) GetEmailProvider() (*Provider, error) {
|
||||
return application.GetProviderByCategory("Email")
|
||||
func (application *Application) GetProviderByCategoryAndRule(category string, method string) (*Provider, error) {
|
||||
providers, err := GetProviders(application.Organization)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
m := map[string]*Provider{}
|
||||
for _, provider := range providers {
|
||||
if provider.Category != category {
|
||||
continue
|
||||
}
|
||||
|
||||
m[provider.Name] = provider
|
||||
}
|
||||
|
||||
for _, providerItem := range application.Providers {
|
||||
if providerItem.Rule == method || providerItem.Rule == "all" {
|
||||
if provider, ok := m[providerItem.Name]; ok {
|
||||
return provider, nil
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (application *Application) GetSmsProvider() (*Provider, error) {
|
||||
return application.GetProviderByCategory("SMS")
|
||||
func (application *Application) GetEmailProvider(method string) (*Provider, error) {
|
||||
return application.GetProviderByCategoryAndRule("Email", method)
|
||||
}
|
||||
|
||||
func (application *Application) GetSmsProvider(method string) (*Provider, error) {
|
||||
return application.GetProviderByCategoryAndRule("SMS", method)
|
||||
}
|
||||
|
||||
func (application *Application) GetStorageProvider() (*Provider, error) {
|
||||
|
@ -1165,7 +1165,7 @@ export function getLoginLink(application) {
|
||||
if (application === null) {
|
||||
url = null;
|
||||
} else if (window.location.pathname.includes("/signup/oauth/authorize")) {
|
||||
url = window.location.href.replace("/signup/oauth/authorize", "/login/oauth/authorize");
|
||||
url = window.location.pathname.replace("/signup/oauth/authorize", "/login/oauth/authorize");
|
||||
} else if (authConfig.appName === application.name) {
|
||||
url = "/login";
|
||||
} else if (application.signinUrl === "") {
|
||||
@ -1173,7 +1173,7 @@ export function getLoginLink(application) {
|
||||
} else {
|
||||
url = application.signinUrl;
|
||||
}
|
||||
return url;
|
||||
return url + window.location.search;
|
||||
}
|
||||
|
||||
export function redirectToLoginPage(application, history) {
|
||||
@ -1216,7 +1216,7 @@ export function renderSignupLink(application, text) {
|
||||
if (application === null) {
|
||||
url = null;
|
||||
} else if (window.location.pathname.includes("/login/oauth/authorize")) {
|
||||
url = window.location.href.replace("/login/oauth/authorize", "/signup/oauth/authorize");
|
||||
url = window.location.pathname.replace("/login/oauth/authorize", "/signup/oauth/authorize");
|
||||
} else if (authConfig.appName === application.name) {
|
||||
url = "/signup";
|
||||
} else {
|
||||
@ -1228,10 +1228,10 @@ export function renderSignupLink(application, text) {
|
||||
}
|
||||
|
||||
const storeSigninUrl = () => {
|
||||
sessionStorage.setItem("signinUrl", window.location.href);
|
||||
sessionStorage.setItem("signinUrl", window.location.pathname + window.location.search);
|
||||
};
|
||||
|
||||
return renderLink(url, text, storeSigninUrl);
|
||||
return renderLink(url + window.location.search, text, storeSigninUrl);
|
||||
}
|
||||
|
||||
export function renderForgetLink(application, text) {
|
||||
@ -1249,7 +1249,7 @@ export function renderForgetLink(application, text) {
|
||||
}
|
||||
|
||||
const storeSigninUrl = () => {
|
||||
sessionStorage.setItem("signinUrl", window.location.href);
|
||||
sessionStorage.setItem("signinUrl", window.location.pathname + window.location.search);
|
||||
};
|
||||
|
||||
return renderLink(url, text, storeSigninUrl);
|
||||
|
@ -156,7 +156,7 @@ class ForgetPage extends React.Component {
|
||||
if (res.status === "ok") {
|
||||
const linkInStorage = sessionStorage.getItem("signinUrl");
|
||||
if (linkInStorage !== null && linkInStorage !== "") {
|
||||
Setting.goToLink(linkInStorage);
|
||||
Setting.goToLinkSoft(linkInStorage);
|
||||
} else {
|
||||
Setting.redirectToLoginPage(this.getApplicationObj(), this.props.history);
|
||||
}
|
||||
|
@ -92,7 +92,7 @@ class ResultPage extends React.Component {
|
||||
<Button type="primary" key="login" onClick={() => {
|
||||
const linkInStorage = sessionStorage.getItem("signinUrl");
|
||||
if (linkInStorage !== null && linkInStorage !== "") {
|
||||
Setting.goToLink(linkInStorage);
|
||||
Setting.goToLinkSoft(this, linkInStorage);
|
||||
} else {
|
||||
Setting.redirectToLoginPage(application, this.props.history);
|
||||
}
|
||||
|
@ -87,8 +87,8 @@ class SignupPage extends React.Component {
|
||||
componentDidMount() {
|
||||
const oAuthParams = Util.getOAuthGetParameters();
|
||||
if (oAuthParams !== null) {
|
||||
const signinUrl = window.location.href.replace("/signup/oauth/authorize", "/login/oauth/authorize");
|
||||
sessionStorage.setItem("signinUrl", signinUrl);
|
||||
const signinUrl = window.location.pathname.replace("/signup/oauth/authorize", "/login/oauth/authorize");
|
||||
sessionStorage.setItem("signinUrl", signinUrl + window.location.search);
|
||||
}
|
||||
|
||||
if (this.getApplicationObj() === undefined) {
|
||||
@ -639,7 +639,7 @@ class SignupPage extends React.Component {
|
||||
<a onClick={() => {
|
||||
const linkInStorage = sessionStorage.getItem("signinUrl");
|
||||
if (linkInStorage !== null && linkInStorage !== "") {
|
||||
Setting.goToLink(linkInStorage);
|
||||
Setting.goToLinkSoft(this, linkInStorage);
|
||||
} else {
|
||||
Setting.redirectToLoginPage(application, this.props.history);
|
||||
}
|
||||
|
@ -223,6 +223,26 @@ class ProviderTable extends React.Component {
|
||||
<Option key="Always" value="Always">{i18next.t("application:Always")}</Option>
|
||||
</Select>
|
||||
);
|
||||
} else if (record.provider?.category === "SMS" || record.provider?.category === "Email") {
|
||||
if (text === "None") {
|
||||
text = "all";
|
||||
}
|
||||
return (
|
||||
<Select virtual={false} style={{width: "100%"}}
|
||||
value={text}
|
||||
defaultValue="all"
|
||||
onChange={value => {
|
||||
this.updateField(table, index, "rule", value);
|
||||
}}>
|
||||
<Option key="all" value="all">{"All"}</Option>
|
||||
<Option key="signup" value="signup">{"Signup"}</Option>
|
||||
<Option key="login" value="login">{"Login"}</Option>
|
||||
<Option key="forget" value="forget">{"Forget Password"}</Option>
|
||||
<Option key="reset" value="reset">{"Reset Password"}</Option>
|
||||
<Option key="mfaSetup" value="mfaSetup">{"Set MFA"}</Option>
|
||||
<Option key="mfaAuth" value="mfaAuth">{"MFA Auth"}</Option>
|
||||
</Select>
|
||||
);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
|
Reference in New Issue
Block a user