Rename module to new repository root
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
package authentication
|
||||
|
||||
import (
|
||||
. "ersteller-lib"
|
||||
. "git.gorlug.de/code/ersteller"
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
|
||||
@@ -6,8 +6,8 @@ import (
|
||||
"encoding/base64"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"ersteller-lib"
|
||||
"ersteller-lib/authentication"
|
||||
"git.gorlug.de/code/ersteller"
|
||||
"git.gorlug.de/code/ersteller/authentication"
|
||||
"github.com/gorilla/sessions"
|
||||
"github.com/labstack/echo/v4"
|
||||
"golang.org/x/oauth2"
|
||||
@@ -35,7 +35,7 @@ type Auth struct {
|
||||
isLocal bool
|
||||
userRepo authentication.UserRepository
|
||||
sessionStore *sessions.CookieStore
|
||||
GoogleLoginRoute ersteller_lib.Route
|
||||
GoogleLoginRoute ersteller.Route
|
||||
environment AuthEnv
|
||||
}
|
||||
|
||||
@@ -64,10 +64,10 @@ func (a *Auth) GetAuthURL(state string) string {
|
||||
func (a *Auth) ParseUserData(code string) (GoogleUserData, error) {
|
||||
data, err := a.getUserDataFromGoogle(code)
|
||||
if err != nil {
|
||||
ersteller_lib.LogError("failed getting user data from Google: %v", err)
|
||||
ersteller.LogError("failed getting user data from Google: %v", err)
|
||||
return GoogleUserData{}, err
|
||||
}
|
||||
ersteller_lib.LogDebug("user data: %v", data)
|
||||
ersteller.LogDebug("user data: %v", data)
|
||||
return data, nil
|
||||
}
|
||||
|
||||
@@ -75,25 +75,25 @@ func (a *Auth) getUserDataFromGoogle(code string) (GoogleUserData, error) {
|
||||
// Use code to get token and get user info from Google.
|
||||
token, err := a.Config.Exchange(context.Background(), code)
|
||||
if err != nil {
|
||||
ersteller_lib.LogError("code exchange wrong: %v", err)
|
||||
ersteller.LogError("code exchange wrong: %v", err)
|
||||
return GoogleUserData{}, err
|
||||
}
|
||||
|
||||
response, err := http.Get(oauthGoogleUrlAPI + token.AccessToken)
|
||||
if err != nil {
|
||||
ersteller_lib.LogError("failed getting user info: %v", err)
|
||||
ersteller.LogError("failed getting user info: %v", err)
|
||||
return GoogleUserData{}, nil
|
||||
}
|
||||
defer response.Body.Close()
|
||||
contents, err := ioutil.ReadAll(response.Body)
|
||||
if err != nil {
|
||||
ersteller_lib.LogError("failed read response: %v", err)
|
||||
ersteller.LogError("failed read response: %v", err)
|
||||
return GoogleUserData{}, nil
|
||||
}
|
||||
userData := GoogleUserData{}
|
||||
err = json.Unmarshal(contents, &userData)
|
||||
if err != nil {
|
||||
ersteller_lib.LogError("failed to unmarshal user data: %v", err)
|
||||
ersteller.LogError("failed to unmarshal user data: %v", err)
|
||||
return GoogleUserData{}, nil
|
||||
}
|
||||
userData.Token = token
|
||||
@@ -102,10 +102,10 @@ func (a *Auth) getUserDataFromGoogle(code string) (GoogleUserData, error) {
|
||||
}
|
||||
|
||||
func (a *Auth) SaveCredentials(userId int, token *oauth2.Token) error {
|
||||
ersteller_lib.Debug("saving google credentials for user ", userId)
|
||||
ersteller.Debug("saving google credentials for user ", userId)
|
||||
googleAuth, err := a.repo.ReadByUserId(userId)
|
||||
if err != nil {
|
||||
ersteller_lib.LogDebug("no GoogleAuth found for user %d, creating new one", userId)
|
||||
ersteller.LogDebug("no GoogleAuth found for user %d, creating new one", userId)
|
||||
_, err = a.repo.Create(GoogleAuth{
|
||||
UserId: userId,
|
||||
Credentials: Credentials{
|
||||
@@ -121,11 +121,11 @@ func (a *Auth) SaveCredentials(userId int, token *oauth2.Token) error {
|
||||
func (a *Auth) GetCredentials(userId int) (*oauth2.Token, error) {
|
||||
credentials, err := a.repo.ReadByUserId(userId)
|
||||
if err != nil {
|
||||
ersteller_lib.LogError("failed to get credentials for user %d: %v", userId, err)
|
||||
ersteller.LogError("failed to get credentials for user %d: %v", userId, err)
|
||||
return nil, err
|
||||
}
|
||||
if credentials.Credentials.Token.AccessToken == "" {
|
||||
ersteller_lib.LogError("no credentials found for user %d", userId)
|
||||
ersteller.LogError("no credentials found for user %d", userId)
|
||||
return nil, errors.New("no credentials found")
|
||||
}
|
||||
return &credentials.Credentials.Token, nil
|
||||
@@ -135,25 +135,25 @@ const oAuthStateCookieName = "oauthstate"
|
||||
const GoogleLogin = "/login/google"
|
||||
const GoogleLoginCallback = "/email/authenticated"
|
||||
|
||||
func (a *Auth) AddRoutes(e *echo.Echo) []ersteller_lib.Route {
|
||||
googleLoginRoute := ersteller_lib.NewGetRoute(GoogleLogin, func(c echo.Context) error {
|
||||
func (a *Auth) AddRoutes(e *echo.Echo) []ersteller.Route {
|
||||
googleLoginRoute := ersteller.NewGetRoute(GoogleLogin, func(c echo.Context) error {
|
||||
state := a.generateStateOauthCookie(c.Response())
|
||||
ersteller_lib.LogDebug("Value: %v", state)
|
||||
ersteller.LogDebug("Value: %v", state)
|
||||
authenticationUrl := a.GetAuthURL(state)
|
||||
return c.Redirect(http.StatusTemporaryRedirect, authenticationUrl)
|
||||
})
|
||||
googleLoginRoute.Add(e)
|
||||
a.GoogleLoginRoute = googleLoginRoute
|
||||
|
||||
authenticatedRoute := ersteller_lib.NewGetRoute(GoogleLoginCallback, func(c echo.Context) error {
|
||||
ersteller_lib.LogDebug("email authenticated called")
|
||||
authenticatedRoute := ersteller.NewGetRoute(GoogleLoginCallback, func(c echo.Context) error {
|
||||
ersteller.LogDebug("email authenticated called")
|
||||
oauthstate, err := c.Cookie(oAuthStateCookieName)
|
||||
if err != nil {
|
||||
ersteller_lib.LogError("Failed to get cookie: %v", err)
|
||||
ersteller.LogError("Failed to get cookie: %v", err)
|
||||
return err
|
||||
}
|
||||
if c.FormValue("state") != oauthstate.Value {
|
||||
ersteller_lib.LogError("Failed to verify google oauth state")
|
||||
ersteller.LogError("Failed to verify google oauth state")
|
||||
return err
|
||||
}
|
||||
code := c.FormValue("code")
|
||||
@@ -163,10 +163,10 @@ func (a *Auth) AddRoutes(e *echo.Echo) []ersteller_lib.Route {
|
||||
}
|
||||
userId, err := a.userRepo.GetUserId(data.Email)
|
||||
if err != nil {
|
||||
ersteller_lib.LogError("Failed to get user id: %v", err)
|
||||
ersteller.LogError("Failed to get user id: %v", err)
|
||||
userId, err = a.userRepo.CreateFromEmail(data.Email)
|
||||
if err != nil {
|
||||
ersteller_lib.LogError("Failed to create user: %v", err)
|
||||
ersteller.LogError("Failed to create user: %v", err)
|
||||
return err
|
||||
}
|
||||
}
|
||||
@@ -176,36 +176,36 @@ func (a *Auth) AddRoutes(e *echo.Echo) []ersteller_lib.Route {
|
||||
}
|
||||
err = a.SaveCredentials(userId, data.Token)
|
||||
if err != nil {
|
||||
ersteller_lib.Error("failed to save credentials for user ", userId, ": ", err)
|
||||
ersteller.Error("failed to save credentials for user ", userId, ": ", err)
|
||||
return err
|
||||
}
|
||||
ersteller_lib.Debug("saved credentials for user", userId)
|
||||
ersteller.Debug("saved credentials for user", userId)
|
||||
return c.Redirect(http.StatusTemporaryRedirect, "/")
|
||||
})
|
||||
authenticatedRoute.Add(e)
|
||||
|
||||
logoutRoute := ersteller_lib.NewGetRoute("/logout", func(c echo.Context) error {
|
||||
logoutRoute := ersteller.NewGetRoute("/logout", func(c echo.Context) error {
|
||||
// Clear the session
|
||||
session, err := a.sessionStore.Get(c.Request(), a.environment.SessionName)
|
||||
if err != nil {
|
||||
ersteller_lib.LogError("Failed to get session: %v", err)
|
||||
ersteller.LogError("Failed to get session: %v", err)
|
||||
return c.Redirect(http.StatusTemporaryRedirect, "/")
|
||||
}
|
||||
session.Options.MaxAge = -1
|
||||
err = session.Save(c.Request(), c.Response())
|
||||
if err != nil {
|
||||
ersteller_lib.LogError("Failed to save session: %v", err)
|
||||
ersteller.LogError("Failed to save session: %v", err)
|
||||
return err
|
||||
}
|
||||
return c.Redirect(http.StatusTemporaryRedirect, "/")
|
||||
})
|
||||
logoutRoute.Add(e)
|
||||
return []ersteller_lib.Route{googleLoginRoute, authenticatedRoute, logoutRoute}
|
||||
return []ersteller.Route{googleLoginRoute, authenticatedRoute, logoutRoute}
|
||||
}
|
||||
func (a *Auth) saveEmailToSessionStore(c echo.Context, email string, userId int) error {
|
||||
session, err := a.sessionStore.New(c.Request(), a.environment.SessionName)
|
||||
if err != nil {
|
||||
ersteller_lib.LogError("Failed to create session: %v", err)
|
||||
ersteller.LogError("Failed to create session: %v", err)
|
||||
return err
|
||||
}
|
||||
session.Values = map[interface{}]interface{}{
|
||||
@@ -214,7 +214,7 @@ func (a *Auth) saveEmailToSessionStore(c echo.Context, email string, userId int)
|
||||
}
|
||||
err = session.Save(c.Request(), c.Response())
|
||||
if err != nil {
|
||||
ersteller_lib.LogError("Failed to save session: %v", err)
|
||||
ersteller.LogError("Failed to save session: %v", err)
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
@@ -224,7 +224,7 @@ func (a *Auth) generateStateOauthCookie(w http.ResponseWriter) string {
|
||||
b := make([]byte, 16)
|
||||
_, err := rand.Read(b)
|
||||
if err != nil {
|
||||
ersteller_lib.LogError("Failed to read random state: %v", err)
|
||||
ersteller.LogError("Failed to read random state: %v", err)
|
||||
}
|
||||
state := base64.URLEncoding.EncodeToString(b)
|
||||
|
||||
|
||||
@@ -3,12 +3,12 @@ package google
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"ersteller-lib"
|
||||
"git.gorlug.de/code/ersteller"
|
||||
"github.com/doug-martin/goqu/v9"
|
||||
)
|
||||
|
||||
func (r *GoogleAuthRepository) ReadByUserId(userId int) (GoogleAuth, error) {
|
||||
ersteller_lib.Debug("Getting GoogleAuth by userId", userId)
|
||||
ersteller.Debug("Getting GoogleAuth by userId", userId)
|
||||
sql, args, _ := r.dialect.From("googleAuth").
|
||||
Prepared(true).
|
||||
Select(r.getSelectColumns()...).
|
||||
@@ -19,7 +19,7 @@ func (r *GoogleAuthRepository) ReadByUserId(userId int) (GoogleAuth, error) {
|
||||
|
||||
rows, err := r.connPool.Query(context.Background(), sql, args...)
|
||||
if err != nil {
|
||||
ersteller_lib.Error("Failed to get GoogleAuth: ", err)
|
||||
ersteller.Error("Failed to get GoogleAuth: ", err)
|
||||
}
|
||||
defer rows.Close()
|
||||
if rows.Next() {
|
||||
|
||||
@@ -7,8 +7,8 @@ import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"ersteller-lib"
|
||||
"fmt"
|
||||
"git.gorlug.de/code/ersteller"
|
||||
"github.com/doug-martin/goqu/v9"
|
||||
_ "github.com/doug-martin/goqu/v9/dialect/postgres"
|
||||
"github.com/doug-martin/goqu/v9/exp"
|
||||
@@ -42,13 +42,13 @@ func (r *GoogleAuthRepository) Create(googleAuth GoogleAuth) (int, error) {
|
||||
Returning("id").
|
||||
ToSQL()
|
||||
if err != nil {
|
||||
ersteller_lib.LogError("error creating create GoogleAuth sql: %v", err)
|
||||
ersteller.LogError("error creating create GoogleAuth sql: %v", err)
|
||||
return -1, err
|
||||
}
|
||||
|
||||
rows, err := r.connPool.Query(context.Background(), sql, args...)
|
||||
if err != nil {
|
||||
ersteller_lib.LogError("error creating GoogleAuth: %v", err)
|
||||
ersteller.LogError("error creating GoogleAuth: %v", err)
|
||||
return -1, err
|
||||
}
|
||||
defer rows.Close()
|
||||
@@ -56,11 +56,11 @@ func (r *GoogleAuthRepository) Create(googleAuth GoogleAuth) (int, error) {
|
||||
if rows.Next() {
|
||||
err = rows.Scan(&id)
|
||||
if err != nil {
|
||||
ersteller_lib.LogError("error scanning User: %v", err)
|
||||
ersteller.LogError("error scanning User: %v", err)
|
||||
return -1, err
|
||||
}
|
||||
} else {
|
||||
ersteller_lib.Error("GoogleAuth already exists")
|
||||
ersteller.Error("GoogleAuth already exists")
|
||||
return -1, GoogleAuthAlreadyExistsError{GoogleAuth: googleAuth}
|
||||
}
|
||||
|
||||
@@ -83,7 +83,7 @@ func (r *GoogleAuthRepository) getSelectColumns() []any {
|
||||
}
|
||||
|
||||
func (r *GoogleAuthRepository) Read(userId int, id int) (GoogleAuth, error) {
|
||||
ersteller_lib.Debug("Getting GoogleAuth by id ", id)
|
||||
ersteller.Debug("Getting GoogleAuth by id ", id)
|
||||
sql, args, _ := r.dialect.From("googleAuth").
|
||||
Prepared(true).
|
||||
Select(r.getSelectColumns()...).
|
||||
@@ -95,7 +95,7 @@ func (r *GoogleAuthRepository) Read(userId int, id int) (GoogleAuth, error) {
|
||||
|
||||
rows, err := r.connPool.Query(context.Background(), sql, args...)
|
||||
if err != nil {
|
||||
ersteller_lib.Error("Failed to get GoogleAuth: ", err)
|
||||
ersteller.Error("Failed to get GoogleAuth: ", err)
|
||||
}
|
||||
defer rows.Close()
|
||||
if rows.Next() {
|
||||
@@ -162,13 +162,13 @@ func (r *GoogleAuthRepository) Update(userId int, googleAuth GoogleAuth) error {
|
||||
}).
|
||||
ToSQL()
|
||||
if err != nil {
|
||||
ersteller_lib.LogError("error creating update GoogleAuth sql: %v", err)
|
||||
ersteller.LogError("error creating update GoogleAuth sql: %v", err)
|
||||
return err
|
||||
}
|
||||
|
||||
_, err = r.connPool.Exec(context.Background(), sql, args...)
|
||||
if err != nil {
|
||||
ersteller_lib.LogError("error updating GoogleAuth: %v", err)
|
||||
ersteller.LogError("error updating GoogleAuth: %v", err)
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -184,13 +184,13 @@ func (r *GoogleAuthRepository) Delete(userId int, id int) error {
|
||||
}).
|
||||
ToSQL()
|
||||
if err != nil {
|
||||
ersteller_lib.LogError("error creating delete GoogleAuth sql: %v", err)
|
||||
ersteller.LogError("error creating delete GoogleAuth sql: %v", err)
|
||||
return err
|
||||
}
|
||||
|
||||
_, err = r.connPool.Exec(context.Background(), sql, args...)
|
||||
if err != nil {
|
||||
ersteller_lib.LogError("error deleting GoogleAuth: %v", err)
|
||||
ersteller.LogError("error deleting GoogleAuth: %v", err)
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -266,7 +266,7 @@ func (r *GoogleAuthRepository) GetPage(params GoogleAuthPaginationParams) ([]Goo
|
||||
|
||||
rows, err := r.connPool.Query(context.Background(), sql, args...)
|
||||
if err != nil {
|
||||
ersteller_lib.LogError("failed to run sql query: %v", err)
|
||||
ersteller.LogError("failed to run sql query: %v", err)
|
||||
return nil, -1, err
|
||||
}
|
||||
defer rows.Close()
|
||||
|
||||
@@ -5,8 +5,8 @@ import (
|
||||
"crypto/rand"
|
||||
"encoding/base64"
|
||||
"encoding/json"
|
||||
. "ersteller-lib"
|
||||
"ersteller-lib/authentication"
|
||||
. "git.gorlug.de/code/ersteller"
|
||||
"git.gorlug.de/code/ersteller/authentication"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
+10
-10
@@ -2,7 +2,7 @@ package authentication
|
||||
|
||||
import (
|
||||
"context"
|
||||
"ersteller-lib"
|
||||
"git.gorlug.de/code/ersteller"
|
||||
"github.com/gorilla/sessions"
|
||||
"github.com/labstack/echo/v4"
|
||||
"github.com/markbates/goth"
|
||||
@@ -38,7 +38,7 @@ func RunKeycloakAuth(e *echo.Echo, environment KeycloakEnv, cookieStore *session
|
||||
// ignore the error for now
|
||||
openid, err := openidConnect.New(environment.Keycloak.ClientId, environment.Keycloak.ClientSecret, environment.BaseUrl+"/auth/openid-connect/callback", environment.Keycloak.DiscoveryUrl)
|
||||
if err != nil {
|
||||
ersteller_lib.Error("Error while initializing OpenID Connect provider: ", err)
|
||||
ersteller.Error("Error while initializing OpenID Connect provider: ", err)
|
||||
panic(err)
|
||||
}
|
||||
if openid != nil {
|
||||
@@ -56,12 +56,12 @@ func RunKeycloakAuth(e *echo.Echo, environment KeycloakEnv, cookieStore *session
|
||||
if userId == -1 {
|
||||
userId, err = createUser(user, userRepo)
|
||||
if err != nil {
|
||||
ersteller_lib.LogError("Failed to create user: %v", err)
|
||||
ersteller.LogError("Failed to create user: %v", err)
|
||||
return err
|
||||
}
|
||||
ersteller_lib.LogDebug("Created user with id %d", userId)
|
||||
ersteller.LogDebug("Created user with id %d", userId)
|
||||
} else {
|
||||
ersteller_lib.LogError("Failed to get user id: %v", err)
|
||||
ersteller.LogError("Failed to get user id: %v", err)
|
||||
return err
|
||||
}
|
||||
}
|
||||
@@ -76,7 +76,7 @@ func RunKeycloakAuth(e *echo.Echo, environment KeycloakEnv, cookieStore *session
|
||||
// Get the session
|
||||
session, err := cookieStore.Get(c.Request(), environment.SessionName)
|
||||
if err != nil {
|
||||
ersteller_lib.LogError("Failed to get session during logout: %v", err)
|
||||
ersteller.LogError("Failed to get session during logout: %v", err)
|
||||
} else {
|
||||
// Clear session values
|
||||
session.Values = make(map[interface{}]interface{})
|
||||
@@ -85,7 +85,7 @@ func RunKeycloakAuth(e *echo.Echo, environment KeycloakEnv, cookieStore *session
|
||||
// Save the session (this will delete the cookie)
|
||||
err = session.Save(c.Request(), c.Response())
|
||||
if err != nil {
|
||||
ersteller_lib.LogError("Failed to clear session during logout: %v", err)
|
||||
ersteller.LogError("Failed to clear session during logout: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -105,7 +105,7 @@ func RunKeycloakAuth(e *echo.Echo, environment KeycloakEnv, cookieStore *session
|
||||
request := c.Request().WithContext(ctx)
|
||||
// try to get the user without re-authenticating
|
||||
if gothUser, err := gothic.CompleteUserAuth(c.Response(), c.Request()); err == nil {
|
||||
ersteller_lib.Debug(gothUser)
|
||||
ersteller.Debug(gothUser)
|
||||
return nil
|
||||
} else {
|
||||
gothic.BeginAuthHandler(c.Response(), request)
|
||||
@@ -122,7 +122,7 @@ func createUser(gothUser goth.User, repo UserRepository) (int, error) {
|
||||
func saveEmailToSessionStore(c echo.Context, sessionStore *sessions.CookieStore, email string, userId int, environment KeycloakEnv) error {
|
||||
session, err := sessionStore.New(c.Request(), environment.SessionName)
|
||||
if err != nil {
|
||||
ersteller_lib.LogError("Failed to create session: %v", err)
|
||||
ersteller.LogError("Failed to create session: %v", err)
|
||||
return err
|
||||
}
|
||||
session.Values = map[interface{}]interface{}{
|
||||
@@ -131,7 +131,7 @@ func saveEmailToSessionStore(c echo.Context, sessionStore *sessions.CookieStore,
|
||||
}
|
||||
err = session.Save(c.Request(), c.Response())
|
||||
if err != nil {
|
||||
ersteller_lib.LogError("Failed to save session: %v", err)
|
||||
ersteller.LogError("Failed to save session: %v", err)
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package authentication
|
||||
|
||||
import (
|
||||
"ersteller-lib"
|
||||
"git.gorlug.de/code/ersteller"
|
||||
"github.com/labstack/echo/v4"
|
||||
"maragu.dev/gomponents"
|
||||
. "maragu.dev/gomponents/html"
|
||||
@@ -10,22 +10,22 @@ import (
|
||||
const LoginPath = "/login"
|
||||
|
||||
type LoginPage struct {
|
||||
createPage ersteller_lib.CreatePageFunc
|
||||
LoginRoute ersteller_lib.GetRoute
|
||||
createPage ersteller.CreatePageFunc
|
||||
LoginRoute ersteller.GetRoute
|
||||
googleLoginUrl string
|
||||
}
|
||||
|
||||
func NewLoginPage(e *echo.Echo, createPage ersteller_lib.CreatePageFunc, googleLoginUrl string) *LoginPage {
|
||||
func NewLoginPage(e *echo.Echo, createPage ersteller.CreatePageFunc, googleLoginUrl string) *LoginPage {
|
||||
page := &LoginPage{createPage: createPage, googleLoginUrl: googleLoginUrl}
|
||||
page.LoginRoute = ersteller_lib.NewGetRoute(LoginPath, page.Render).Add(e)
|
||||
page.LoginRoute = ersteller.NewGetRoute(LoginPath, page.Render).Add(e)
|
||||
return page
|
||||
}
|
||||
|
||||
func (l *LoginPage) Render(c echo.Context) error {
|
||||
return l.createPage(c, ersteller_lib.PageWebsiteMetaData{
|
||||
Title: ersteller_lib.NewI18nText(map[ersteller_lib.Language]string{
|
||||
ersteller_lib.En: "Login",
|
||||
ersteller_lib.De: "Anmelden",
|
||||
return l.createPage(c, ersteller.PageWebsiteMetaData{
|
||||
Title: ersteller.NewI18nText(map[ersteller.Language]string{
|
||||
ersteller.En: "Login",
|
||||
ersteller.De: "Anmelden",
|
||||
}),
|
||||
HideNavigation: true,
|
||||
}, l.getLoginPage())
|
||||
|
||||
@@ -2,7 +2,7 @@ package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"ersteller-lib"
|
||||
"git.gorlug.de/code/ersteller"
|
||||
"github.com/joho/godotenv"
|
||||
"os"
|
||||
)
|
||||
@@ -10,13 +10,13 @@ import (
|
||||
func main() {
|
||||
err := godotenv.Load()
|
||||
if err != nil {
|
||||
ersteller_lib.LogError("Error loading .env file: %v", err)
|
||||
ersteller.LogError("Error loading .env file: %v", err)
|
||||
panic(err)
|
||||
}
|
||||
dbUrl := os.Getenv("DATABASE_URL")
|
||||
connpool, err := ersteller_lib.CreatePostgresConnpool(dbUrl)
|
||||
connpool, err := ersteller.CreatePostgresConnpool(dbUrl)
|
||||
if err != nil {
|
||||
ersteller_lib.LogError("Failed to create connection pool: %v", err)
|
||||
ersteller.LogError("Failed to create connection pool: %v", err)
|
||||
panic(err)
|
||||
}
|
||||
// https://medium.com/israeli-tech-radar/postgresql-trigger-based-audit-log-fd9d9d5e412c
|
||||
@@ -133,7 +133,7 @@ CREATE OR REPLACE TRIGGER audit_log_trigger
|
||||
`
|
||||
_, err = connpool.Exec(context.Background(), sql)
|
||||
if err != nil {
|
||||
ersteller_lib.LogError("Failed to create audit log table: %v", err)
|
||||
ersteller.LogError("Failed to create audit log table: %v", err)
|
||||
panic(err)
|
||||
}
|
||||
println("Created audit log table")
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
module ersteller-lib
|
||||
module git.gorlug.de/code/ersteller
|
||||
|
||||
go 1.25.0
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package ersteller_lib
|
||||
package ersteller
|
||||
|
||||
// https://medium.com/@rnp0728/secure-password-hashing-in-go-a-comprehensive-guide-5500e19e7c1f
|
||||
import "golang.org/x/crypto/bcrypt"
|
||||
|
||||
+3
-3
@@ -2,7 +2,7 @@ package htmx
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"ersteller-lib"
|
||||
"git.gorlug.de/code/ersteller"
|
||||
"github.com/labstack/echo/v4"
|
||||
)
|
||||
|
||||
@@ -15,10 +15,10 @@ type LocationRedirectParams struct {
|
||||
func LocationRedirect(c echo.Context, params LocationRedirectParams) error {
|
||||
jsonData, err := json.Marshal(params)
|
||||
if err != nil {
|
||||
ersteller_lib.Error("Failed to marshal LocationRedirectParams ", params, err)
|
||||
ersteller.Error("Failed to marshal LocationRedirectParams ", params, err)
|
||||
return err
|
||||
}
|
||||
ersteller_lib.Debug("LocationRedirectParams", params, "jsonData", string(jsonData))
|
||||
ersteller.Debug("LocationRedirectParams", params, "jsonData", string(jsonData))
|
||||
c.Response().Header().Set("HX-Location", string(jsonData))
|
||||
return nil
|
||||
}
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package ersteller_lib
|
||||
package ersteller
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package ersteller_lib
|
||||
package ersteller
|
||||
|
||||
type Language string
|
||||
|
||||
|
||||
+2
-2
@@ -3,8 +3,8 @@ package llm
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"ersteller-lib"
|
||||
"fmt"
|
||||
"git.gorlug.de/code/ersteller"
|
||||
"io"
|
||||
"net/http"
|
||||
)
|
||||
@@ -151,7 +151,7 @@ type MistralClient interface {
|
||||
type MistralClientMock struct{}
|
||||
|
||||
func (m MistralClientMock) CreateChatCompletion(req *ChatCompletionRequest) (*ChatCompletionResponse, error) {
|
||||
ersteller_lib.Debug("mocking the mistral client")
|
||||
ersteller.Debug("mocking the mistral client")
|
||||
response := ChatCompletionResponse{
|
||||
Choices: []ChatCompletionChoice{
|
||||
{
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package ersteller_lib
|
||||
package ersteller
|
||||
|
||||
import (
|
||||
"compress/gzip"
|
||||
|
||||
+1
-1
@@ -1,3 +1,3 @@
|
||||
package ersteller_lib
|
||||
package ersteller
|
||||
|
||||
// https://github.com/golang-migrate/migrate
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package ersteller_lib
|
||||
package ersteller
|
||||
|
||||
import (
|
||||
"github.com/labstack/echo/v4"
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package ersteller_lib
|
||||
package ersteller
|
||||
|
||||
import (
|
||||
"encoding/base64"
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package ersteller_lib
|
||||
package ersteller
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
package ersteller_lib
|
||||
package ersteller
|
||||
|
||||
// https://entgo.io/docs/getting-started/#setup-a-go-environment
|
||||
|
||||
@@ -9,11 +9,11 @@ import (
|
||||
"log"
|
||||
"reflect"
|
||||
|
||||
"ersteller-lib/schema/ent/example/ent/migrate"
|
||||
"git.gorlug.de/code/ersteller/schema/ent/example/ent/migrate"
|
||||
|
||||
"ersteller-lib/schema/ent/example/ent/group"
|
||||
"ersteller-lib/schema/ent/example/ent/todo"
|
||||
"ersteller-lib/schema/ent/example/ent/user"
|
||||
"git.gorlug.de/code/ersteller/schema/ent/example/ent/group"
|
||||
"git.gorlug.de/code/ersteller/schema/ent/example/ent/todo"
|
||||
"git.gorlug.de/code/ersteller/schema/ent/example/ent/user"
|
||||
|
||||
"entgo.io/ent"
|
||||
"entgo.io/ent/dialect"
|
||||
|
||||
@@ -5,10 +5,10 @@ package ent
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"ersteller-lib/schema/ent/example/ent/group"
|
||||
"ersteller-lib/schema/ent/example/ent/todo"
|
||||
"ersteller-lib/schema/ent/example/ent/user"
|
||||
"fmt"
|
||||
"git.gorlug.de/code/ersteller/schema/ent/example/ent/group"
|
||||
"git.gorlug.de/code/ersteller/schema/ent/example/ent/todo"
|
||||
"git.gorlug.de/code/ersteller/schema/ent/example/ent/user"
|
||||
"reflect"
|
||||
"sync"
|
||||
|
||||
|
||||
@@ -5,11 +5,11 @@ package enttest
|
||||
import (
|
||||
"context"
|
||||
|
||||
"ersteller-lib/schema/ent/example/ent"
|
||||
"git.gorlug.de/code/ersteller/schema/ent/example/ent"
|
||||
// required by schema hooks.
|
||||
_ "ersteller-lib/schema/ent/example/ent/runtime"
|
||||
_ "git.gorlug.de/code/ersteller/schema/ent/example/ent/runtime"
|
||||
|
||||
"ersteller-lib/schema/ent/example/ent/migrate"
|
||||
"git.gorlug.de/code/ersteller/schema/ent/example/ent/migrate"
|
||||
|
||||
"entgo.io/ent/dialect/sql/schema"
|
||||
)
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
package ent
|
||||
|
||||
import (
|
||||
"ersteller-lib/schema/ent/example/ent/group"
|
||||
"fmt"
|
||||
"git.gorlug.de/code/ersteller/schema/ent/example/ent/group"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
package group
|
||||
|
||||
import (
|
||||
"ersteller-lib/schema/ent/example/ent/predicate"
|
||||
"git.gorlug.de/code/ersteller/schema/ent/example/ent/predicate"
|
||||
"time"
|
||||
|
||||
"entgo.io/ent/dialect/sql"
|
||||
|
||||
@@ -5,10 +5,10 @@ package ent
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"ersteller-lib/schema/ent/example/ent/group"
|
||||
"ersteller-lib/schema/ent/example/ent/todo"
|
||||
"ersteller-lib/schema/ent/example/ent/user"
|
||||
"fmt"
|
||||
"git.gorlug.de/code/ersteller/schema/ent/example/ent/group"
|
||||
"git.gorlug.de/code/ersteller/schema/ent/example/ent/todo"
|
||||
"git.gorlug.de/code/ersteller/schema/ent/example/ent/user"
|
||||
"time"
|
||||
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
|
||||
@@ -4,8 +4,8 @@ package ent
|
||||
|
||||
import (
|
||||
"context"
|
||||
"ersteller-lib/schema/ent/example/ent/group"
|
||||
"ersteller-lib/schema/ent/example/ent/predicate"
|
||||
"git.gorlug.de/code/ersteller/schema/ent/example/ent/group"
|
||||
"git.gorlug.de/code/ersteller/schema/ent/example/ent/predicate"
|
||||
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
|
||||
@@ -5,11 +5,11 @@ package ent
|
||||
import (
|
||||
"context"
|
||||
"database/sql/driver"
|
||||
"ersteller-lib/schema/ent/example/ent/group"
|
||||
"ersteller-lib/schema/ent/example/ent/predicate"
|
||||
"ersteller-lib/schema/ent/example/ent/todo"
|
||||
"ersteller-lib/schema/ent/example/ent/user"
|
||||
"fmt"
|
||||
"git.gorlug.de/code/ersteller/schema/ent/example/ent/group"
|
||||
"git.gorlug.de/code/ersteller/schema/ent/example/ent/predicate"
|
||||
"git.gorlug.de/code/ersteller/schema/ent/example/ent/todo"
|
||||
"git.gorlug.de/code/ersteller/schema/ent/example/ent/user"
|
||||
"math"
|
||||
|
||||
"entgo.io/ent"
|
||||
|
||||
@@ -5,11 +5,11 @@ package ent
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"ersteller-lib/schema/ent/example/ent/group"
|
||||
"ersteller-lib/schema/ent/example/ent/predicate"
|
||||
"ersteller-lib/schema/ent/example/ent/todo"
|
||||
"ersteller-lib/schema/ent/example/ent/user"
|
||||
"fmt"
|
||||
"git.gorlug.de/code/ersteller/schema/ent/example/ent/group"
|
||||
"git.gorlug.de/code/ersteller/schema/ent/example/ent/predicate"
|
||||
"git.gorlug.de/code/ersteller/schema/ent/example/ent/todo"
|
||||
"git.gorlug.de/code/ersteller/schema/ent/example/ent/user"
|
||||
"time"
|
||||
|
||||
"entgo.io/ent/dialect/sql"
|
||||
|
||||
@@ -4,8 +4,8 @@ package hook
|
||||
|
||||
import (
|
||||
"context"
|
||||
"ersteller-lib/schema/ent/example/ent"
|
||||
"fmt"
|
||||
"git.gorlug.de/code/ersteller/schema/ent/example/ent"
|
||||
)
|
||||
|
||||
// The GroupFunc type is an adapter to allow the use of ordinary
|
||||
|
||||
@@ -5,11 +5,11 @@ package ent
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"ersteller-lib/schema/ent/example/ent/group"
|
||||
"ersteller-lib/schema/ent/example/ent/predicate"
|
||||
"ersteller-lib/schema/ent/example/ent/todo"
|
||||
"ersteller-lib/schema/ent/example/ent/user"
|
||||
"fmt"
|
||||
"git.gorlug.de/code/ersteller/schema/ent/example/ent/group"
|
||||
"git.gorlug.de/code/ersteller/schema/ent/example/ent/predicate"
|
||||
"git.gorlug.de/code/ersteller/schema/ent/example/ent/todo"
|
||||
"git.gorlug.de/code/ersteller/schema/ent/example/ent/user"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
|
||||
@@ -3,10 +3,10 @@
|
||||
package ent
|
||||
|
||||
import (
|
||||
"ersteller-lib/schema/ent/example/ent/group"
|
||||
"ersteller-lib/schema/ent/example/ent/schema"
|
||||
"ersteller-lib/schema/ent/example/ent/todo"
|
||||
"ersteller-lib/schema/ent/example/ent/user"
|
||||
"git.gorlug.de/code/ersteller/schema/ent/example/ent/group"
|
||||
"git.gorlug.de/code/ersteller/schema/ent/example/ent/schema"
|
||||
"git.gorlug.de/code/ersteller/schema/ent/example/ent/todo"
|
||||
"git.gorlug.de/code/ersteller/schema/ent/example/ent/user"
|
||||
"time"
|
||||
)
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package schema
|
||||
|
||||
import (
|
||||
"ersteller-lib/schema/ent"
|
||||
"git.gorlug.de/code/ersteller/schema/ent"
|
||||
|
||||
"entgo.io/ent"
|
||||
"entgo.io/ent/schema/edge"
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package schema
|
||||
|
||||
import (
|
||||
"ersteller-lib/schema/ent"
|
||||
"git.gorlug.de/code/ersteller/schema/ent"
|
||||
|
||||
"entgo.io/ent"
|
||||
"entgo.io/ent/schema/edge"
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package schema
|
||||
|
||||
import (
|
||||
"ersteller-lib/schema/ent"
|
||||
"git.gorlug.de/code/ersteller/schema/ent"
|
||||
|
||||
"entgo.io/ent"
|
||||
"entgo.io/ent/schema/edge"
|
||||
|
||||
@@ -3,9 +3,9 @@
|
||||
package ent
|
||||
|
||||
import (
|
||||
"ersteller-lib/schema/ent/example/ent/group"
|
||||
"ersteller-lib/schema/ent/example/ent/todo"
|
||||
"fmt"
|
||||
"git.gorlug.de/code/ersteller/schema/ent/example/ent/group"
|
||||
"git.gorlug.de/code/ersteller/schema/ent/example/ent/todo"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
package todo
|
||||
|
||||
import (
|
||||
"ersteller-lib/schema/ent/example/ent/predicate"
|
||||
"git.gorlug.de/code/ersteller/schema/ent/example/ent/predicate"
|
||||
"time"
|
||||
|
||||
"entgo.io/ent/dialect/sql"
|
||||
|
||||
@@ -5,9 +5,9 @@ package ent
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"ersteller-lib/schema/ent/example/ent/group"
|
||||
"ersteller-lib/schema/ent/example/ent/todo"
|
||||
"fmt"
|
||||
"git.gorlug.de/code/ersteller/schema/ent/example/ent/group"
|
||||
"git.gorlug.de/code/ersteller/schema/ent/example/ent/todo"
|
||||
"time"
|
||||
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
|
||||
@@ -4,8 +4,8 @@ package ent
|
||||
|
||||
import (
|
||||
"context"
|
||||
"ersteller-lib/schema/ent/example/ent/predicate"
|
||||
"ersteller-lib/schema/ent/example/ent/todo"
|
||||
"git.gorlug.de/code/ersteller/schema/ent/example/ent/predicate"
|
||||
"git.gorlug.de/code/ersteller/schema/ent/example/ent/todo"
|
||||
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
|
||||
@@ -4,10 +4,10 @@ package ent
|
||||
|
||||
import (
|
||||
"context"
|
||||
"ersteller-lib/schema/ent/example/ent/group"
|
||||
"ersteller-lib/schema/ent/example/ent/predicate"
|
||||
"ersteller-lib/schema/ent/example/ent/todo"
|
||||
"fmt"
|
||||
"git.gorlug.de/code/ersteller/schema/ent/example/ent/group"
|
||||
"git.gorlug.de/code/ersteller/schema/ent/example/ent/predicate"
|
||||
"git.gorlug.de/code/ersteller/schema/ent/example/ent/todo"
|
||||
"math"
|
||||
|
||||
"entgo.io/ent"
|
||||
|
||||
@@ -5,10 +5,10 @@ package ent
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"ersteller-lib/schema/ent/example/ent/group"
|
||||
"ersteller-lib/schema/ent/example/ent/predicate"
|
||||
"ersteller-lib/schema/ent/example/ent/todo"
|
||||
"fmt"
|
||||
"git.gorlug.de/code/ersteller/schema/ent/example/ent/group"
|
||||
"git.gorlug.de/code/ersteller/schema/ent/example/ent/predicate"
|
||||
"git.gorlug.de/code/ersteller/schema/ent/example/ent/todo"
|
||||
"time"
|
||||
|
||||
"entgo.io/ent/dialect/sql"
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
package ent
|
||||
|
||||
import (
|
||||
"ersteller-lib/schema/ent/example/ent/user"
|
||||
"fmt"
|
||||
"git.gorlug.de/code/ersteller/schema/ent/example/ent/user"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
package user
|
||||
|
||||
import (
|
||||
"ersteller-lib/schema/ent/example/ent/predicate"
|
||||
"git.gorlug.de/code/ersteller/schema/ent/example/ent/predicate"
|
||||
"time"
|
||||
|
||||
"entgo.io/ent/dialect/sql"
|
||||
|
||||
@@ -5,9 +5,9 @@ package ent
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"ersteller-lib/schema/ent/example/ent/group"
|
||||
"ersteller-lib/schema/ent/example/ent/user"
|
||||
"fmt"
|
||||
"git.gorlug.de/code/ersteller/schema/ent/example/ent/group"
|
||||
"git.gorlug.de/code/ersteller/schema/ent/example/ent/user"
|
||||
"time"
|
||||
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
|
||||
@@ -4,8 +4,8 @@ package ent
|
||||
|
||||
import (
|
||||
"context"
|
||||
"ersteller-lib/schema/ent/example/ent/predicate"
|
||||
"ersteller-lib/schema/ent/example/ent/user"
|
||||
"git.gorlug.de/code/ersteller/schema/ent/example/ent/predicate"
|
||||
"git.gorlug.de/code/ersteller/schema/ent/example/ent/user"
|
||||
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
|
||||
@@ -5,10 +5,10 @@ package ent
|
||||
import (
|
||||
"context"
|
||||
"database/sql/driver"
|
||||
"ersteller-lib/schema/ent/example/ent/group"
|
||||
"ersteller-lib/schema/ent/example/ent/predicate"
|
||||
"ersteller-lib/schema/ent/example/ent/user"
|
||||
"fmt"
|
||||
"git.gorlug.de/code/ersteller/schema/ent/example/ent/group"
|
||||
"git.gorlug.de/code/ersteller/schema/ent/example/ent/predicate"
|
||||
"git.gorlug.de/code/ersteller/schema/ent/example/ent/user"
|
||||
"math"
|
||||
|
||||
"entgo.io/ent"
|
||||
|
||||
@@ -5,10 +5,10 @@ package ent
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"ersteller-lib/schema/ent/example/ent/group"
|
||||
"ersteller-lib/schema/ent/example/ent/predicate"
|
||||
"ersteller-lib/schema/ent/example/ent/user"
|
||||
"fmt"
|
||||
"git.gorlug.de/code/ersteller/schema/ent/example/ent/group"
|
||||
"git.gorlug.de/code/ersteller/schema/ent/example/ent/predicate"
|
||||
"git.gorlug.de/code/ersteller/schema/ent/example/ent/user"
|
||||
"time"
|
||||
|
||||
"entgo.io/ent/dialect/sql"
|
||||
|
||||
@@ -2,11 +2,11 @@ package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"ersteller-lib/schema/ent/example/ent"
|
||||
"ersteller-lib/schema/ent/example/ent/group"
|
||||
"ersteller-lib/schema/ent/example/ent/todo"
|
||||
"ersteller-lib/schema/ent/example/ent/user"
|
||||
"fmt"
|
||||
"git.gorlug.de/code/ersteller/schema/ent/example/ent"
|
||||
"git.gorlug.de/code/ersteller/schema/ent/example/ent/group"
|
||||
"git.gorlug.de/code/ersteller/schema/ent/example/ent/todo"
|
||||
"git.gorlug.de/code/ersteller/schema/ent/example/ent/user"
|
||||
"log"
|
||||
"time"
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package ersteller_lib
|
||||
package ersteller
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
@@ -2,8 +2,8 @@ package create
|
||||
|
||||
import (
|
||||
. "ersteller-lib"
|
||||
"ersteller-lib/starter/env"
|
||||
"fmt"
|
||||
"git.gorlug.de/code/ersteller/starter/env"
|
||||
"log"
|
||||
"os"
|
||||
"os/exec"
|
||||
|
||||
@@ -9,11 +9,11 @@ import (
|
||||
"log"
|
||||
"reflect"
|
||||
|
||||
"ersteller-lib/starter/ent/migrate"
|
||||
"git.gorlug.de/code/ersteller/starter/ent/migrate"
|
||||
|
||||
"ersteller-lib/starter/ent/googleauth"
|
||||
"ersteller-lib/starter/ent/todo"
|
||||
"ersteller-lib/starter/ent/user"
|
||||
"git.gorlug.de/code/ersteller/starter/ent/googleauth"
|
||||
"git.gorlug.de/code/ersteller/starter/ent/todo"
|
||||
"git.gorlug.de/code/ersteller/starter/ent/user"
|
||||
|
||||
"entgo.io/ent"
|
||||
"entgo.io/ent/dialect"
|
||||
|
||||
+3
-3
@@ -5,10 +5,10 @@ package ent
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"ersteller-lib/starter/ent/googleauth"
|
||||
"ersteller-lib/starter/ent/todo"
|
||||
"ersteller-lib/starter/ent/user"
|
||||
"fmt"
|
||||
"git.gorlug.de/code/ersteller/starter/ent/googleauth"
|
||||
"git.gorlug.de/code/ersteller/starter/ent/todo"
|
||||
"git.gorlug.de/code/ersteller/starter/ent/user"
|
||||
"reflect"
|
||||
"sync"
|
||||
|
||||
|
||||
@@ -5,11 +5,11 @@ package enttest
|
||||
import (
|
||||
"context"
|
||||
|
||||
"ersteller-lib/starter/ent"
|
||||
"git.gorlug.de/code/ersteller/starter/ent"
|
||||
// required by schema hooks.
|
||||
_ "ersteller-lib/starter/ent/runtime"
|
||||
_ "git.gorlug.de/code/ersteller/starter/ent/runtime"
|
||||
|
||||
"ersteller-lib/starter/ent/migrate"
|
||||
"git.gorlug.de/code/ersteller/starter/ent/migrate"
|
||||
|
||||
"entgo.io/ent/dialect/sql/schema"
|
||||
)
|
||||
|
||||
@@ -4,10 +4,10 @@ package ent
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"ersteller-lib/starter/ent/googleauth"
|
||||
"ersteller-lib/starter/ent/schema"
|
||||
"ersteller-lib/starter/ent/user"
|
||||
"fmt"
|
||||
"git.gorlug.de/code/ersteller/starter/ent/googleauth"
|
||||
"git.gorlug.de/code/ersteller/starter/ent/schema"
|
||||
"git.gorlug.de/code/ersteller/starter/ent/user"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
package googleauth
|
||||
|
||||
import (
|
||||
"ersteller-lib/starter/ent/predicate"
|
||||
"git.gorlug.de/code/ersteller/starter/ent/predicate"
|
||||
"time"
|
||||
|
||||
"entgo.io/ent/dialect/sql"
|
||||
|
||||
@@ -5,10 +5,10 @@ package ent
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"ersteller-lib/starter/ent/googleauth"
|
||||
"ersteller-lib/starter/ent/schema"
|
||||
"ersteller-lib/starter/ent/user"
|
||||
"fmt"
|
||||
"git.gorlug.de/code/ersteller/starter/ent/googleauth"
|
||||
"git.gorlug.de/code/ersteller/starter/ent/schema"
|
||||
"git.gorlug.de/code/ersteller/starter/ent/user"
|
||||
"time"
|
||||
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
|
||||
@@ -4,8 +4,8 @@ package ent
|
||||
|
||||
import (
|
||||
"context"
|
||||
"ersteller-lib/starter/ent/googleauth"
|
||||
"ersteller-lib/starter/ent/predicate"
|
||||
"git.gorlug.de/code/ersteller/starter/ent/googleauth"
|
||||
"git.gorlug.de/code/ersteller/starter/ent/predicate"
|
||||
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
|
||||
@@ -4,10 +4,10 @@ package ent
|
||||
|
||||
import (
|
||||
"context"
|
||||
"ersteller-lib/starter/ent/googleauth"
|
||||
"ersteller-lib/starter/ent/predicate"
|
||||
"ersteller-lib/starter/ent/user"
|
||||
"fmt"
|
||||
"git.gorlug.de/code/ersteller/starter/ent/googleauth"
|
||||
"git.gorlug.de/code/ersteller/starter/ent/predicate"
|
||||
"git.gorlug.de/code/ersteller/starter/ent/user"
|
||||
"math"
|
||||
|
||||
"entgo.io/ent"
|
||||
|
||||
@@ -5,11 +5,11 @@ package ent
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"ersteller-lib/starter/ent/googleauth"
|
||||
"ersteller-lib/starter/ent/predicate"
|
||||
"ersteller-lib/starter/ent/schema"
|
||||
"ersteller-lib/starter/ent/user"
|
||||
"fmt"
|
||||
"git.gorlug.de/code/ersteller/starter/ent/googleauth"
|
||||
"git.gorlug.de/code/ersteller/starter/ent/predicate"
|
||||
"git.gorlug.de/code/ersteller/starter/ent/schema"
|
||||
"git.gorlug.de/code/ersteller/starter/ent/user"
|
||||
"time"
|
||||
|
||||
"entgo.io/ent/dialect/sql"
|
||||
|
||||
@@ -4,8 +4,8 @@ package hook
|
||||
|
||||
import (
|
||||
"context"
|
||||
"ersteller-lib/starter/ent"
|
||||
"fmt"
|
||||
"git.gorlug.de/code/ersteller/starter/ent"
|
||||
)
|
||||
|
||||
// The GoogleAuthFunc type is an adapter to allow the use of ordinary
|
||||
|
||||
@@ -5,12 +5,12 @@ package ent
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"ersteller-lib/starter/ent/googleauth"
|
||||
"ersteller-lib/starter/ent/predicate"
|
||||
"ersteller-lib/starter/ent/schema"
|
||||
"ersteller-lib/starter/ent/todo"
|
||||
"ersteller-lib/starter/ent/user"
|
||||
"fmt"
|
||||
"git.gorlug.de/code/ersteller/starter/ent/googleauth"
|
||||
"git.gorlug.de/code/ersteller/starter/ent/predicate"
|
||||
"git.gorlug.de/code/ersteller/starter/ent/schema"
|
||||
"git.gorlug.de/code/ersteller/starter/ent/todo"
|
||||
"git.gorlug.de/code/ersteller/starter/ent/user"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
|
||||
@@ -3,10 +3,10 @@
|
||||
package ent
|
||||
|
||||
import (
|
||||
"ersteller-lib/starter/ent/googleauth"
|
||||
"ersteller-lib/starter/ent/schema"
|
||||
"ersteller-lib/starter/ent/todo"
|
||||
"ersteller-lib/starter/ent/user"
|
||||
"git.gorlug.de/code/ersteller/starter/ent/googleauth"
|
||||
"git.gorlug.de/code/ersteller/starter/ent/schema"
|
||||
"git.gorlug.de/code/ersteller/starter/ent/todo"
|
||||
"git.gorlug.de/code/ersteller/starter/ent/user"
|
||||
"time"
|
||||
)
|
||||
|
||||
|
||||
+2
-2
@@ -3,9 +3,9 @@
|
||||
package ent
|
||||
|
||||
import (
|
||||
"ersteller-lib/starter/ent/todo"
|
||||
"ersteller-lib/starter/ent/user"
|
||||
"fmt"
|
||||
"git.gorlug.de/code/ersteller/starter/ent/todo"
|
||||
"git.gorlug.de/code/ersteller/starter/ent/user"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
package todo
|
||||
|
||||
import (
|
||||
"ersteller-lib/starter/ent/predicate"
|
||||
"git.gorlug.de/code/ersteller/starter/ent/predicate"
|
||||
"time"
|
||||
|
||||
"entgo.io/ent/dialect/sql"
|
||||
|
||||
@@ -5,9 +5,9 @@ package ent
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"ersteller-lib/starter/ent/todo"
|
||||
"ersteller-lib/starter/ent/user"
|
||||
"fmt"
|
||||
"git.gorlug.de/code/ersteller/starter/ent/todo"
|
||||
"git.gorlug.de/code/ersteller/starter/ent/user"
|
||||
"time"
|
||||
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
|
||||
@@ -4,8 +4,8 @@ package ent
|
||||
|
||||
import (
|
||||
"context"
|
||||
"ersteller-lib/starter/ent/predicate"
|
||||
"ersteller-lib/starter/ent/todo"
|
||||
"git.gorlug.de/code/ersteller/starter/ent/predicate"
|
||||
"git.gorlug.de/code/ersteller/starter/ent/todo"
|
||||
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
|
||||
@@ -4,10 +4,10 @@ package ent
|
||||
|
||||
import (
|
||||
"context"
|
||||
"ersteller-lib/starter/ent/predicate"
|
||||
"ersteller-lib/starter/ent/todo"
|
||||
"ersteller-lib/starter/ent/user"
|
||||
"fmt"
|
||||
"git.gorlug.de/code/ersteller/starter/ent/predicate"
|
||||
"git.gorlug.de/code/ersteller/starter/ent/todo"
|
||||
"git.gorlug.de/code/ersteller/starter/ent/user"
|
||||
"math"
|
||||
|
||||
"entgo.io/ent"
|
||||
|
||||
@@ -5,10 +5,10 @@ package ent
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"ersteller-lib/starter/ent/predicate"
|
||||
"ersteller-lib/starter/ent/todo"
|
||||
"ersteller-lib/starter/ent/user"
|
||||
"fmt"
|
||||
"git.gorlug.de/code/ersteller/starter/ent/predicate"
|
||||
"git.gorlug.de/code/ersteller/starter/ent/todo"
|
||||
"git.gorlug.de/code/ersteller/starter/ent/user"
|
||||
"time"
|
||||
|
||||
"entgo.io/ent/dialect/sql"
|
||||
|
||||
+1
-1
@@ -3,8 +3,8 @@
|
||||
package ent
|
||||
|
||||
import (
|
||||
"ersteller-lib/starter/ent/user"
|
||||
"fmt"
|
||||
"git.gorlug.de/code/ersteller/starter/ent/user"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
package user
|
||||
|
||||
import (
|
||||
"ersteller-lib/starter/ent/predicate"
|
||||
"git.gorlug.de/code/ersteller/starter/ent/predicate"
|
||||
"time"
|
||||
|
||||
"entgo.io/ent/dialect/sql"
|
||||
|
||||
@@ -5,8 +5,8 @@ package ent
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"ersteller-lib/starter/ent/user"
|
||||
"fmt"
|
||||
"git.gorlug.de/code/ersteller/starter/ent/user"
|
||||
"time"
|
||||
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
|
||||
@@ -4,8 +4,8 @@ package ent
|
||||
|
||||
import (
|
||||
"context"
|
||||
"ersteller-lib/starter/ent/predicate"
|
||||
"ersteller-lib/starter/ent/user"
|
||||
"git.gorlug.de/code/ersteller/starter/ent/predicate"
|
||||
"git.gorlug.de/code/ersteller/starter/ent/user"
|
||||
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
|
||||
@@ -4,9 +4,9 @@ package ent
|
||||
|
||||
import (
|
||||
"context"
|
||||
"ersteller-lib/starter/ent/predicate"
|
||||
"ersteller-lib/starter/ent/user"
|
||||
"fmt"
|
||||
"git.gorlug.de/code/ersteller/starter/ent/predicate"
|
||||
"git.gorlug.de/code/ersteller/starter/ent/user"
|
||||
"math"
|
||||
|
||||
"entgo.io/ent"
|
||||
|
||||
@@ -5,9 +5,9 @@ package ent
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"ersteller-lib/starter/ent/predicate"
|
||||
"ersteller-lib/starter/ent/user"
|
||||
"fmt"
|
||||
"git.gorlug.de/code/ersteller/starter/ent/predicate"
|
||||
"git.gorlug.de/code/ersteller/starter/ent/user"
|
||||
"time"
|
||||
|
||||
"entgo.io/ent/dialect/sql"
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"ersteller-lib/starter/create"
|
||||
"git.gorlug.de/code/ersteller/starter/create"
|
||||
"log"
|
||||
"path"
|
||||
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
module ersteller-lib/starter
|
||||
module git.gorlug.de/code/ersteller/starter
|
||||
|
||||
go 1.25.0
|
||||
|
||||
|
||||
@@ -4,8 +4,8 @@ import (
|
||||
"context"
|
||||
ersteller_lib "ersteller-lib"
|
||||
google_http "ersteller-lib/authentication/google/http"
|
||||
"ersteller-lib/starter/ent"
|
||||
"ersteller-lib/starter/ent/user"
|
||||
"git.gorlug.de/code/ersteller/starter/ent"
|
||||
"git.gorlug.de/code/ersteller/starter/ent/user"
|
||||
)
|
||||
|
||||
type Database struct {
|
||||
|
||||
+3
-3
@@ -3,9 +3,9 @@ package main
|
||||
import (
|
||||
"context"
|
||||
. "ersteller-lib"
|
||||
"ersteller-lib/starter/ent"
|
||||
"ersteller-lib/starter/env"
|
||||
"ersteller-lib/starter/routes"
|
||||
"git.gorlug.de/code/ersteller/starter/ent"
|
||||
"git.gorlug.de/code/ersteller/starter/env"
|
||||
"git.gorlug.de/code/ersteller/starter/routes"
|
||||
"log"
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
@@ -4,15 +4,15 @@ import (
|
||||
. "ersteller-lib"
|
||||
"ersteller-lib/authentication"
|
||||
google_http "ersteller-lib/authentication/google/http"
|
||||
"ersteller-lib/starter/about"
|
||||
"ersteller-lib/starter/contact"
|
||||
"ersteller-lib/starter/ent"
|
||||
"ersteller-lib/starter/env"
|
||||
"ersteller-lib/starter/google"
|
||||
"ersteller-lib/starter/index"
|
||||
"ersteller-lib/starter/login"
|
||||
"ersteller-lib/starter/page"
|
||||
"ersteller-lib/starter/todos"
|
||||
"git.gorlug.de/code/ersteller/starter/about"
|
||||
"git.gorlug.de/code/ersteller/starter/contact"
|
||||
"git.gorlug.de/code/ersteller/starter/ent"
|
||||
"git.gorlug.de/code/ersteller/starter/env"
|
||||
"git.gorlug.de/code/ersteller/starter/google"
|
||||
"git.gorlug.de/code/ersteller/starter/index"
|
||||
"git.gorlug.de/code/ersteller/starter/login"
|
||||
"git.gorlug.de/code/ersteller/starter/page"
|
||||
"git.gorlug.de/code/ersteller/starter/todos"
|
||||
"net/http"
|
||||
|
||||
"github.com/gorilla/sessions"
|
||||
|
||||
@@ -7,8 +7,8 @@ import (
|
||||
"strings"
|
||||
|
||||
. "ersteller-lib"
|
||||
"ersteller-lib/starter/ent"
|
||||
"ersteller-lib/starter/ent/todo"
|
||||
"git.gorlug.de/code/ersteller/starter/ent"
|
||||
"git.gorlug.de/code/ersteller/starter/ent/todo"
|
||||
|
||||
. "maragu.dev/gomponents"
|
||||
. "maragu.dev/gomponents/html"
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package ersteller_lib
|
||||
package ersteller
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package ersteller_lib
|
||||
package ersteller
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
+15
-15
@@ -4,8 +4,8 @@ import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"ersteller-lib"
|
||||
"fmt"
|
||||
"git.gorlug.de/code/ersteller"
|
||||
"github.com/doug-martin/goqu/v9"
|
||||
_ "github.com/doug-martin/goqu/v9/dialect/postgres"
|
||||
"github.com/doug-martin/goqu/v9/exp"
|
||||
@@ -41,13 +41,13 @@ func (r *UserRepository) Create(user User) (int, error) {
|
||||
Returning("id").
|
||||
ToSQL()
|
||||
if err != nil {
|
||||
ersteller_lib.LogError("error creating create User sql: %v", err)
|
||||
ersteller.LogError("error creating create User sql: %v", err)
|
||||
return -1, err
|
||||
}
|
||||
|
||||
rows, err := r.connPool.Query(context.Background(), sql, args...)
|
||||
if err != nil {
|
||||
ersteller_lib.LogError("error creating User: %v", err)
|
||||
ersteller.LogError("error creating User: %v", err)
|
||||
return -1, err
|
||||
}
|
||||
defer rows.Close()
|
||||
@@ -55,11 +55,11 @@ func (r *UserRepository) Create(user User) (int, error) {
|
||||
if rows.Next() {
|
||||
err = rows.Scan(&id)
|
||||
if err != nil {
|
||||
ersteller_lib.LogError("error scanning User: %v", err)
|
||||
ersteller.LogError("error scanning User: %v", err)
|
||||
return -1, err
|
||||
}
|
||||
} else {
|
||||
ersteller_lib.Error("User already exists")
|
||||
ersteller.Error("User already exists")
|
||||
return -1, UserAlreadyExistsError{User: user}
|
||||
}
|
||||
|
||||
@@ -82,7 +82,7 @@ func (r *UserRepository) getSelectColumns() []any {
|
||||
}
|
||||
|
||||
func (r *UserRepository) Read(id int) (User, error) {
|
||||
ersteller_lib.Debug("Getting User by id ", id)
|
||||
ersteller.Debug("Getting User by id ", id)
|
||||
sql, args, _ := r.dialect.From("user").
|
||||
Prepared(true).
|
||||
Select(r.getSelectColumns()...).
|
||||
@@ -93,7 +93,7 @@ func (r *UserRepository) Read(id int) (User, error) {
|
||||
|
||||
rows, err := r.connPool.Query(context.Background(), sql, args...)
|
||||
if err != nil {
|
||||
ersteller_lib.Error("Failed to get User: ", err)
|
||||
ersteller.Error("Failed to get User: ", err)
|
||||
}
|
||||
defer rows.Close()
|
||||
if rows.Next() {
|
||||
@@ -167,13 +167,13 @@ func (r *UserRepository) Update(user User) error {
|
||||
}).
|
||||
ToSQL()
|
||||
if err != nil {
|
||||
ersteller_lib.LogError("error creating update User sql: %v", err)
|
||||
ersteller.LogError("error creating update User sql: %v", err)
|
||||
return err
|
||||
}
|
||||
|
||||
_, err = r.connPool.Exec(context.Background(), sql, args...)
|
||||
if err != nil {
|
||||
ersteller_lib.LogError("error updating User: %v", err)
|
||||
ersteller.LogError("error updating User: %v", err)
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -188,13 +188,13 @@ func (r *UserRepository) Delete(id int) error {
|
||||
}).
|
||||
ToSQL()
|
||||
if err != nil {
|
||||
ersteller_lib.LogError("error creating delete User sql: %v", err)
|
||||
ersteller.LogError("error creating delete User sql: %v", err)
|
||||
return err
|
||||
}
|
||||
|
||||
_, err = r.connPool.Exec(context.Background(), sql, args...)
|
||||
if err != nil {
|
||||
ersteller_lib.LogError("error deleting User: %v", err)
|
||||
ersteller.LogError("error deleting User: %v", err)
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -285,7 +285,7 @@ func (r *UserRepository) GetPage(params UserPaginationParams) ([]User, int, erro
|
||||
|
||||
rows, err := r.connPool.Query(context.Background(), sql, args...)
|
||||
if err != nil {
|
||||
ersteller_lib.LogError("failed to run sql query: %v", err)
|
||||
ersteller.LogError("failed to run sql query: %v", err)
|
||||
return nil, -1, err
|
||||
}
|
||||
defer rows.Close()
|
||||
@@ -342,7 +342,7 @@ func (r *UserRepository) DoesUserEmailExist(email string) (bool, error) {
|
||||
|
||||
rows, err := r.connPool.Query(context.Background(), sql, args...)
|
||||
if err != nil {
|
||||
ersteller_lib.LogError("failed to run sql query: %v", err)
|
||||
ersteller.LogError("failed to run sql query: %v", err)
|
||||
return false, err
|
||||
}
|
||||
defer rows.Close()
|
||||
@@ -366,7 +366,7 @@ func (r *UserRepository) GetUserId(email string) (int, error) {
|
||||
|
||||
rows, err := r.connPool.Query(context.Background(), sql, args...)
|
||||
if err != nil {
|
||||
ersteller_lib.LogError("failed to run sql query: %v", err)
|
||||
ersteller.LogError("failed to run sql query: %v", err)
|
||||
return -1, err
|
||||
}
|
||||
defer rows.Close()
|
||||
@@ -396,5 +396,5 @@ func (r *UserRepository) VerifyPassword(email string, password string) (bool, in
|
||||
if err != nil {
|
||||
return false, -1, err
|
||||
}
|
||||
return ersteller_lib.VerifyPassword(password, user.Password), userId, nil
|
||||
return ersteller.VerifyPassword(password, user.Password), userId, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user