Skip to content

Commit

Permalink
merge main branch
Browse files Browse the repository at this point in the history
  • Loading branch information
lunny committed Sep 23, 2021
1 parent e34146b commit 3b52492
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 32 deletions.
4 changes: 2 additions & 2 deletions models/login/oauth2.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func (err ErrOAuthApplicationNotFound) Error() string {
// GetActiveOAuth2ProviderLoginSources returns all actived LoginOAuth2 sources
func GetActiveOAuth2ProviderLoginSources() ([]*Source, error) {
sources := make([]*Source, 0, 1)
if err := db.DefaultContext().Engine().Where("is_active = ? and type = ?", true, OAuth2).Find(&sources); err != nil {
if err := db.GetEngine(db.DefaultContext).Where("is_active = ? and type = ?", true, OAuth2).Find(&sources); err != nil {
return nil, err
}
return sources, nil
Expand All @@ -61,7 +61,7 @@ func GetActiveOAuth2ProviderLoginSources() ([]*Source, error) {
// GetActiveOAuth2LoginSourceByName returns a OAuth2 LoginSource based on the given name
func GetActiveOAuth2LoginSourceByName(name string) (*Source, error) {
loginSource := new(Source)
has, err := db.DefaultContext().Engine().Where("name = ? and type = ? and is_active = ?", name, OAuth2, true).Get(loginSource)
has, err := db.GetEngine(db.DefaultContext).Where("name = ? and type = ? and is_active = ?", name, OAuth2, true).Get(loginSource)
if !has || err != nil {
return nil, err
}
Expand Down
27 changes: 0 additions & 27 deletions models/oauth2.go

This file was deleted.

6 changes: 3 additions & 3 deletions services/auth/login_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (

// DeleteLoginSource deletes a LoginSource record in DB.
func DeleteLoginSource(source *login.Source) error {
count, err := db.DefaultContext().Engine().Count(&models.User{LoginSource: source.ID})
count, err := db.GetEngine(db.DefaultContext).Count(&models.User{LoginSource: source.ID})
if err != nil {
return err
} else if count > 0 {
Expand All @@ -21,7 +21,7 @@ func DeleteLoginSource(source *login.Source) error {
}
}

count, err = db.DefaultContext().Engine().Count(&models.ExternalLoginUser{LoginSourceID: source.ID})
count, err = db.GetEngine(db.DefaultContext).Count(&models.ExternalLoginUser{LoginSourceID: source.ID})
if err != nil {
return err
} else if count > 0 {
Expand All @@ -36,6 +36,6 @@ func DeleteLoginSource(source *login.Source) error {
}
}

_, err = db.DefaultContext().Engine().ID(source.ID).Delete(new(login.Source))
_, err = db.GetEngine(db.DefaultContext).ID(source.ID).Delete(new(login.Source))
return err
}

0 comments on commit 3b52492

Please sign in to comment.