Started working on new user registration

This commit is contained in:
2017-06-22 20:51:11 +02:00
parent 0ca8bb0f3d
commit cf0d47bfb0
3 changed files with 120 additions and 1 deletions

View File

@ -92,6 +92,13 @@ func InstallGoogleAuth(app *aero.Application) {
user, getErr := arn.GetUserFromTable("GoogleToUser", googleUser.Sub)
if getErr == nil && user != nil {
// Add GoogleToUser reference
user.Accounts.Google.ID = googleUser.Sub
arn.DB.Set("GoogleToUser", googleUser.Sub, &arn.GoogleToUser{
ID: googleUser.Sub,
UserID: user.ID,
})
session.Set("userId", user.ID)
return ctx.Redirect("/")
}
@ -104,6 +111,18 @@ func InstallGoogleAuth(app *aero.Application) {
return ctx.Redirect("/")
}
return ctx.Error(http.StatusForbidden, "Account does not exist", getErr)
user = arn.NewUser()
user.Nick = "g" + googleUser.Sub
user.Email = googleUser.Email
user.FirstName = googleUser.GivenName
user.LastName = googleUser.FamilyName
user.Gender = googleUser.Gender
user.Accounts.Google.ID = googleUser.Sub
user.LastLogin = arn.DateTimeUTC()
arn.PrettyPrint(user)
// arn.RegisterUser(user)
return ctx.Error(http.StatusForbidden, "Account does not exist", nil)
})
}