Save credentials for google in the database
This commit is contained in:
@@ -5,12 +5,13 @@ import (
|
||||
"crypto/rand"
|
||||
"encoding/base64"
|
||||
"encoding/json"
|
||||
. "git.gorlug.de/code/ersteller"
|
||||
"git.gorlug.de/code/ersteller/authentication"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
. "git.gorlug.de/code/ersteller"
|
||||
"git.gorlug.de/code/ersteller/authentication"
|
||||
|
||||
"github.com/gorilla/sessions"
|
||||
|
||||
"golang.org/x/oauth2"
|
||||
@@ -39,6 +40,7 @@ type GoogleAuth struct {
|
||||
type Database interface {
|
||||
GetUserIdByEmail(ctx context.Context, email string) (int, error)
|
||||
CreateUser(ctx context.Context, email string) (int, error)
|
||||
SaveCredentials(ctx context.Context, userId int, token *oauth2.Token) error
|
||||
}
|
||||
|
||||
type Environment struct {
|
||||
@@ -180,7 +182,10 @@ func (g *GoogleAuth) getUserDataFromGoogle(code string) (GoogleUserData, error)
|
||||
|
||||
func (g *GoogleAuth) SaveCredentials(userId int, token *oauth2.Token) error {
|
||||
Debug("saving google credentials for user ", userId)
|
||||
// For now, we'll just log this - in a real implementation you'd save to database
|
||||
err := g.db.SaveCredentials(context.Background(), userId, token)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
Debug("saved credentials for user", userId)
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user