mirror of
https://github.com/casdoor/casdoor.git
synced 2025-05-24 08:20:31 +08:00
Improve provider check.
This commit is contained in:
parent
05222c7a29
commit
6aeadfa3bd
@ -212,10 +212,16 @@ func (c *ApiController) Login() {
|
|||||||
organization := object.GetOrganization(fmt.Sprintf("%s/%s", "admin", application.Organization))
|
organization := object.GetOrganization(fmt.Sprintf("%s/%s", "admin", application.Organization))
|
||||||
provider := object.GetProvider(fmt.Sprintf("admin/%s", form.Provider))
|
provider := object.GetProvider(fmt.Sprintf("admin/%s", form.Provider))
|
||||||
providerItem := application.GetProviderItem(provider.Name)
|
providerItem := application.GetProviderItem(provider.Name)
|
||||||
|
if !providerItem.IsProviderVisible() {
|
||||||
|
resp = &Response{Status: "error", Msg: fmt.Sprintf("The provider: %s is not enabled for the application", provider.Name)}
|
||||||
|
c.Data["json"] = resp
|
||||||
|
c.ServeJSON()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
idProvider := idp.GetIdProvider(provider.Type, provider.ClientId, provider.ClientSecret, form.RedirectUri)
|
idProvider := idp.GetIdProvider(provider.Type, provider.ClientId, provider.ClientSecret, form.RedirectUri)
|
||||||
if idProvider == nil {
|
if idProvider == nil {
|
||||||
resp = &Response{Status: "error", Msg: fmt.Sprintf("provider: %s does not exist", provider.Type)}
|
resp = &Response{Status: "error", Msg: fmt.Sprintf("The provider type: %s is not supported", provider.Type)}
|
||||||
c.Data["json"] = resp
|
c.Data["json"] = resp
|
||||||
c.ServeJSON()
|
c.ServeJSON()
|
||||||
return
|
return
|
||||||
|
@ -33,10 +33,10 @@ func (application *Application) GetProviderItem(providerName string) *ProviderIt
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (pi *ProviderItem) isProviderVisible() bool {
|
func (pi *ProviderItem) IsProviderVisible() bool {
|
||||||
return pi.Provider.Category == "OAuth"
|
return pi.Provider.Category == "OAuth"
|
||||||
}
|
}
|
||||||
|
|
||||||
func (pi *ProviderItem) isProviderPrompted() bool {
|
func (pi *ProviderItem) isProviderPrompted() bool {
|
||||||
return pi.isProviderVisible() && pi.Prompted
|
return pi.IsProviderVisible() && pi.Prompted
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user