Add google authentication
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
package google
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"ersteller-lib"
|
||||
"github.com/doug-martin/goqu/v9"
|
||||
)
|
||||
|
||||
func (r *GoogleAuthRepository) ReadByUserId(userId int) (GoogleAuth, error) {
|
||||
ersteller_lib.Debug("Getting GoogleAuth by userId", userId)
|
||||
sql, args, _ := r.dialect.From("googleAuth").
|
||||
Prepared(true).
|
||||
Select(r.getSelectColumns()...).
|
||||
Where(goqu.Ex{
|
||||
"user_id": userId,
|
||||
}).
|
||||
ToSQL()
|
||||
|
||||
rows, err := r.connPool.Query(context.Background(), sql, args...)
|
||||
if err != nil {
|
||||
ersteller_lib.Error("Failed to get GoogleAuth: ", err)
|
||||
}
|
||||
defer rows.Close()
|
||||
if rows.Next() {
|
||||
item, _, err := r.rowToItem(rows, false)
|
||||
return item, err
|
||||
}
|
||||
return GoogleAuth{}, errors.New("no rows found")
|
||||
}
|
||||
Reference in New Issue
Block a user