From 35c7aaaa2470ce474cbef3e788cb61a381836098 Mon Sep 17 00:00:00 2001 From: Eduard Urbach Date: Tue, 5 Mar 2019 15:26:48 +0900 Subject: [PATCH] Connect accounts when logging in via email --- auth/facebook.go | 3 +++ auth/google.go | 3 +++ auth/twitter.go | 3 +++ 3 files changed, 9 insertions(+) diff --git a/auth/facebook.go b/auth/facebook.go index fc967e9c..aa47b601 100644 --- a/auth/facebook.go +++ b/auth/facebook.go @@ -121,6 +121,9 @@ func InstallFacebookAuth(app *aero.Application) { if getErr == nil && user != nil { authLog.Info("User logged in via Facebook ID", user.ID, user.Nick, ctx.RealIP(), user.Email, user.RealName()) + // Add FacebookToUser reference + user.ConnectFacebook(fbUser.ID) + user.LastLogin = arn.DateTimeUTC() user.Save() diff --git a/auth/google.go b/auth/google.go index 8926bcf2..820324cf 100644 --- a/auth/google.go +++ b/auth/google.go @@ -145,6 +145,9 @@ func InstallGoogleAuth(app *aero.Application) { if getErr == nil && user != nil { authLog.Info("User logged in via Email", user.ID, user.Nick, ctx.RealIP(), user.Email, user.RealName()) + // Add GoogleToUser reference + user.ConnectGoogle(googleUser.Sub) + user.LastLogin = arn.DateTimeUTC() user.Save() diff --git a/auth/twitter.go b/auth/twitter.go index f7106708..de0266ae 100644 --- a/auth/twitter.go +++ b/auth/twitter.go @@ -142,6 +142,9 @@ func InstallTwitterAuth(app *aero.Application) { if getErr == nil && user != nil { authLog.Info("User logged in via Email", user.ID, user.Nick, ctx.RealIP(), user.Email, user.RealName()) + // Add TwitterToUser reference + user.ConnectTwitter(twUser.ID) + user.LastLogin = arn.DateTimeUTC() user.Save()