aboutsummaryrefslogtreecommitdiffstats
path: root/modules/base/conf.go
diff options
context:
space:
mode:
authorUnknown <joe2010xtmf@163.com>2014-04-07 12:56:40 -0400
committerUnknown <joe2010xtmf@163.com>2014-04-07 12:56:40 -0400
commit9ea9818d3255e5b08293205e278240dece36687d (patch)
tree51c6a65586843082f451ee1e93082fec5784ccd2 /modules/base/conf.go
parent05fb34eacdbec59fb8bcdf96c82c0855e6ec78d2 (diff)
downloadgitea-9ea9818d3255e5b08293205e278240dece36687d.tar.gz
gitea-9ea9818d3255e5b08293205e278240dece36687d.zip
Fix issue with log in with GitHub but need more error handle after
Diffstat (limited to 'modules/base/conf.go')
-rw-r--r--modules/base/conf.go53
1 files changed, 42 insertions, 11 deletions
diff --git a/modules/base/conf.go b/modules/base/conf.go
index 0a618ab1d2..ba9c320d77 100644
--- a/modules/base/conf.go
+++ b/modules/base/conf.go
@@ -22,13 +22,21 @@ import (
"github.com/gogits/gogs/modules/log"
)
-// Mailer represents a mail service.
+// Mailer represents mail service.
type Mailer struct {
Name string
Host string
User, Passwd string
}
+// Oauther represents oauth service.
+type Oauther struct {
+ GitHub struct {
+ Enabled bool
+ ClientId, ClientSecret string
+ }
+}
+
var (
AppVer string
AppName string
@@ -45,8 +53,9 @@ var (
CookieUserName string
CookieRememberName string
- Cfg *goconfig.ConfigFile
- MailService *Mailer
+ Cfg *goconfig.ConfigFile
+ MailService *Mailer
+ OauthService *Oauther
LogMode string
LogConfig string
@@ -206,15 +215,17 @@ func newSessionService() {
func newMailService() {
// Check mailer setting.
- if Cfg.MustBool("mailer", "ENABLED") {
- MailService = &Mailer{
- Name: Cfg.MustValue("mailer", "NAME", AppName),
- Host: Cfg.MustValue("mailer", "HOST"),
- User: Cfg.MustValue("mailer", "USER"),
- Passwd: Cfg.MustValue("mailer", "PASSWD"),
- }
- log.Info("Mail Service Enabled")
+ if !Cfg.MustBool("mailer", "ENABLED") {
+ return
+ }
+
+ MailService = &Mailer{
+ Name: Cfg.MustValue("mailer", "NAME", AppName),
+ Host: Cfg.MustValue("mailer", "HOST"),
+ User: Cfg.MustValue("mailer", "USER"),
+ Passwd: Cfg.MustValue("mailer", "PASSWD"),
}
+ log.Info("Mail Service Enabled")
}
func newRegisterMailService() {
@@ -239,6 +250,25 @@ func newNotifyMailService() {
log.Info("Notify Mail Service Enabled")
}
+func newOauthService() {
+ if !Cfg.MustBool("oauth", "ENABLED") {
+ return
+ }
+
+ OauthService = &Oauther{}
+ oauths := make([]string, 0, 10)
+
+ // GitHub.
+ if Cfg.MustBool("oauth.github", "ENABLED") {
+ OauthService.GitHub.Enabled = true
+ OauthService.GitHub.ClientId = Cfg.MustValue("oauth.github", "CLIENT_ID")
+ OauthService.GitHub.ClientSecret = Cfg.MustValue("oauth.github", "CLIENT_SECRET")
+ oauths = append(oauths, "GitHub")
+ }
+
+ log.Info("Oauth Service Enabled %s", oauths)
+}
+
func NewConfigContext() {
//var err error
workDir, err := ExecDir()
@@ -303,4 +333,5 @@ func NewServices() {
newMailService()
newRegisterMailService()
newNotifyMailService()
+ newOauthService()
}