Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

oauth2.go 885B

12345678910111213141516171819202122232425
  1. // Copyright 2017 The Gitea Authors. All rights reserved.
  2. // Use of this source code is governed by a MIT-style
  3. // license that can be found in the LICENSE file.
  4. package models
  5. // GetActiveOAuth2ProviderLoginSources returns all actived LoginOAuth2 sources
  6. func GetActiveOAuth2ProviderLoginSources() ([]*LoginSource, error) {
  7. sources := make([]*LoginSource, 0, 1)
  8. if err := x.Where("is_active = ? and type = ?", true, LoginOAuth2).Find(&sources); err != nil {
  9. return nil, err
  10. }
  11. return sources, nil
  12. }
  13. // GetActiveOAuth2LoginSourceByName returns a OAuth2 LoginSource based on the given name
  14. func GetActiveOAuth2LoginSourceByName(name string) (*LoginSource, error) {
  15. loginSource := new(LoginSource)
  16. has, err := x.Where("name = ? and type = ? and is_active = ?", name, LoginOAuth2, true).Get(loginSource)
  17. if !has || err != nil {
  18. return nil, err
  19. }
  20. return loginSource, nil
  21. }