mirror of
https://github.com/casdoor/casdoor.git
synced 2025-07-08 09:01:00 +08:00
Compare commits
3 Commits
Author | SHA1 | Date | |
---|---|---|---|
3400fa1e9c | |||
bdc5c92ef0 | |||
4e3eedf246 |
@ -49,8 +49,24 @@ func (c *ApiController) SendVerificationCode() {
|
|||||||
applicationId := c.Ctx.Request.Form.Get("applicationId")
|
applicationId := c.Ctx.Request.Form.Get("applicationId")
|
||||||
remoteAddr := util.GetIPFromRequest(c.Ctx.Request)
|
remoteAddr := util.GetIPFromRequest(c.Ctx.Request)
|
||||||
|
|
||||||
if destType == "" || dest == "" || applicationId == "" || !strings.Contains(applicationId, "/") || checkType == "" {
|
if destType == "" {
|
||||||
c.ResponseError("Missing parameter.")
|
c.ResponseError("Missing parameter: type.")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if dest == "" {
|
||||||
|
c.ResponseError("Missing parameter: dest.")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if applicationId == "" {
|
||||||
|
c.ResponseError("Missing parameter: applicationId.")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if !strings.Contains(applicationId, "/") {
|
||||||
|
c.ResponseError("Wrong parameter: applicationId.")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if checkType == "" {
|
||||||
|
c.ResponseError("Missing parameter: checkType.")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -236,7 +236,7 @@ func CheckAccessPermission(userId string, application *Application) (bool, error
|
|||||||
allowed := true
|
allowed := true
|
||||||
var err error
|
var err error
|
||||||
for _, permission := range permissions {
|
for _, permission := range permissions {
|
||||||
if !permission.IsEnabled {
|
if !permission.IsEnabled || len(permission.Users) == 0 {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,6 +25,7 @@ import (
|
|||||||
func InitDb() {
|
func InitDb() {
|
||||||
existed := initBuiltInOrganization()
|
existed := initBuiltInOrganization()
|
||||||
if !existed {
|
if !existed {
|
||||||
|
initBuiltInPermission()
|
||||||
initBuiltInProvider()
|
initBuiltInProvider()
|
||||||
initBuiltInUser()
|
initBuiltInUser()
|
||||||
initBuiltInApplication()
|
initBuiltInApplication()
|
||||||
@ -230,3 +231,25 @@ func initBuiltInProvider() {
|
|||||||
func initWebAuthn() {
|
func initWebAuthn() {
|
||||||
gob.Register(webauthn.SessionData{})
|
gob.Register(webauthn.SessionData{})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func initBuiltInPermission() {
|
||||||
|
permission := GetPermission("built-in/permission-built-in")
|
||||||
|
if permission != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
permission = &Permission{
|
||||||
|
Owner: "built-in",
|
||||||
|
Name: "permission-built-in",
|
||||||
|
CreatedTime: util.GetCurrentTime(),
|
||||||
|
DisplayName: "Built-in Permission",
|
||||||
|
Users: []string{"built-in/admin"},
|
||||||
|
Roles: []string{},
|
||||||
|
ResourceType: "Application",
|
||||||
|
Resources: []string{"app-built-in"},
|
||||||
|
Actions: []string{"Read", "Write", "Admin"},
|
||||||
|
Effect: "Allow",
|
||||||
|
IsEnabled: true,
|
||||||
|
}
|
||||||
|
AddPermission(permission)
|
||||||
|
}
|
||||||
|
@ -235,6 +235,8 @@ class App extends Component {
|
|||||||
AuthBackend.logout()
|
AuthBackend.logout()
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
if (res.status === "ok") {
|
if (res.status === "ok") {
|
||||||
|
const owner = this.state.account.owner;
|
||||||
|
|
||||||
this.setState({
|
this.setState({
|
||||||
account: null
|
account: null
|
||||||
});
|
});
|
||||||
@ -243,7 +245,9 @@ class App extends Component {
|
|||||||
let redirectUri = res.data2;
|
let redirectUri = res.data2;
|
||||||
if (redirectUri !== null && redirectUri !== undefined && redirectUri !== "") {
|
if (redirectUri !== null && redirectUri !== undefined && redirectUri !== "") {
|
||||||
Setting.goToLink(redirectUri);
|
Setting.goToLink(redirectUri);
|
||||||
}else{
|
} else if (owner !== "built-in") {
|
||||||
|
Setting.goToLink(`${window.location.origin}/login/${owner}`);
|
||||||
|
} else {
|
||||||
Setting.goToLinkSoft(this, "/");
|
Setting.goToLinkSoft(this, "/");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -669,6 +673,7 @@ class App extends Component {
|
|||||||
<Route exact path="/signup" render={(props) => this.renderHomeIfLoggedIn(<SignupPage account={this.state.account} {...props} />)} />
|
<Route exact path="/signup" render={(props) => this.renderHomeIfLoggedIn(<SignupPage account={this.state.account} {...props} />)} />
|
||||||
<Route exact path="/signup/:applicationName" render={(props) => this.renderHomeIfLoggedIn(<SignupPage account={this.state.account} {...props} onUpdateAccount={(account) => {this.onUpdateAccount(account);}} />)} />
|
<Route exact path="/signup/:applicationName" render={(props) => this.renderHomeIfLoggedIn(<SignupPage account={this.state.account} {...props} onUpdateAccount={(account) => {this.onUpdateAccount(account);}} />)} />
|
||||||
<Route exact path="/login" render={(props) => this.renderHomeIfLoggedIn(<SelfLoginPage account={this.state.account} {...props} />)} />
|
<Route exact path="/login" render={(props) => this.renderHomeIfLoggedIn(<SelfLoginPage account={this.state.account} {...props} />)} />
|
||||||
|
<Route exact path="/login/:owner" render={(props) => this.renderHomeIfLoggedIn(<SelfLoginPage account={this.state.account} {...props} />)} />
|
||||||
<Route exact path="/auto-signup/oauth/authorize" render={(props) => <LoginPage account={this.state.account} type={"code"} mode={"signup"} {...props} onUpdateAccount={(account) => {this.onUpdateAccount(account);}} />} />
|
<Route exact path="/auto-signup/oauth/authorize" render={(props) => <LoginPage account={this.state.account} type={"code"} mode={"signup"} {...props} onUpdateAccount={(account) => {this.onUpdateAccount(account);}} />} />
|
||||||
<Route exact path="/signup/oauth/authorize" render={(props) => <SignupPage account={this.state.account} {...props} onUpdateAccount={(account) => {this.onUpdateAccount(account);}} />} />
|
<Route exact path="/signup/oauth/authorize" render={(props) => <SignupPage account={this.state.account} {...props} onUpdateAccount={(account) => {this.onUpdateAccount(account);}} />} />
|
||||||
<Route exact path="/login/oauth/authorize" render={(props) => <LoginPage account={this.state.account} type={"code"} mode={"signin"} {...props} onUpdateAccount={(account) => {this.onUpdateAccount(account);}} />} />
|
<Route exact path="/login/oauth/authorize" render={(props) => <LoginPage account={this.state.account} type={"code"} mode={"signin"} {...props} onUpdateAccount={(account) => {this.onUpdateAccount(account);}} />} />
|
||||||
|
@ -191,6 +191,10 @@ class LoginPage extends React.Component {
|
|||||||
values["type"] = "saml";
|
values["type"] = "saml";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (this.state.owner != null) {
|
||||||
|
values["organization"] = this.state.owner;
|
||||||
|
}
|
||||||
|
|
||||||
AuthBackend.login(values, oAuthParams)
|
AuthBackend.login(values, oAuthParams)
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
if (res.status === "ok") {
|
if (res.status === "ok") {
|
||||||
@ -692,7 +696,7 @@ class LoginPage extends React.Component {
|
|||||||
>
|
>
|
||||||
<CountDownInput
|
<CountDownInput
|
||||||
disabled={this.state.username?.length === 0 || !this.state.validEmailOrPhone}
|
disabled={this.state.username?.length === 0 || !this.state.validEmailOrPhone}
|
||||||
onButtonClickArgs={[this.state.username, "", Setting.getApplicationOrgName(application), true]}
|
onButtonClickArgs={[this.state.username, this.state.validEmail ? "email" : "phone", Setting.getApplicationName(application)]}
|
||||||
/>
|
/>
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
) : (
|
) : (
|
||||||
|
Reference in New Issue
Block a user