mirror of
https://github.com/samsonjs/retrogit.git
synced 2026-04-27 15:07:43 +00:00
Don't clobber the existing Account instance when signing in as an existing user.
This commit is contained in:
parent
7a81416850
commit
8aa6b897e2
1 changed files with 8 additions and 3 deletions
|
|
@ -14,6 +14,7 @@ import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"appengine"
|
"appengine"
|
||||||
|
"appengine/datastore"
|
||||||
"appengine/delay"
|
"appengine/delay"
|
||||||
"appengine/mail"
|
"appengine/mail"
|
||||||
"appengine/urlfetch"
|
"appengine/urlfetch"
|
||||||
|
|
@ -310,10 +311,14 @@ func githubOAuthCallbackHandler(w http.ResponseWriter, r *http.Request) *AppErro
|
||||||
return GitHubFetchError(err, "user")
|
return GitHubFetchError(err, "user")
|
||||||
}
|
}
|
||||||
|
|
||||||
account := &Account{
|
account, err := getAccount(c, *user.ID)
|
||||||
GitHubUserId: *user.ID,
|
if err != nil && err != datastore.ErrNoSuchEntity {
|
||||||
OAuthToken: *token,
|
return InternalError(err, "Could not look up user")
|
||||||
}
|
}
|
||||||
|
if account == nil {
|
||||||
|
account = &Account{GitHubUserId: *user.ID}
|
||||||
|
}
|
||||||
|
account.OAuthToken = *token
|
||||||
err = account.Put(c)
|
err = account.Put(c)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return InternalError(err, "Could not save user")
|
return InternalError(err, "Could not save user")
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue