1
1
mirror of https://github.com/go-gitea/gitea synced 2025-07-22 18:28:37 +00:00

Page: Manage social accounts

This commit is contained in:
Unknwon
2014-08-09 17:25:02 -07:00
parent 08c6d07aad
commit 78defd238c
14 changed files with 148 additions and 123 deletions

View File

@@ -10,6 +10,7 @@ import (
"fmt"
"net/url"
"strings"
"time"
"github.com/gogits/gogs/models"
"github.com/gogits/gogs/modules/log"
@@ -67,8 +68,8 @@ func SocialSignIn(ctx *middleware.Context) {
oa, err := models.GetOauth2(ui.Identity)
switch err {
case nil:
ctx.Session.Set("userId", oa.User.Id)
ctx.Session.Set("userName", oa.User.Name)
ctx.Session.Set("uid", oa.User.Id)
ctx.Session.Set("uname", oa.User.Name)
case models.ErrOauth2RecordNotExist:
raw, _ := json.Marshal(tk)
oa = &models.Oauth2{
@@ -89,6 +90,11 @@ func SocialSignIn(ctx *middleware.Context) {
return
}
oa.Updated = time.Now()
if err = models.UpdateOauth2(oa); err != nil {
log.Error(4, "UpdateOauth2: %v", err)
}
ctx.Session.Set("socialId", oa.Id)
ctx.Session.Set("socialName", ui.Name)
ctx.Session.Set("socialEmail", ui.Email)