don't use session

This commit is contained in:
2025-01-23 14:54:05 -06:00
parent 665341961d
commit 7f6c828ea5
5 changed files with 1 additions and 58 deletions

View File

@@ -189,6 +189,7 @@ func (n *NKodeAPI) Login(customerId entities.CustomerId, userEmail entities.User
return nil, err return nil, err
} }
} }
jwtToken, err := security.NewAuthenticationTokens(string(user.Email), uuid.UUID(customerId)) jwtToken, err := security.NewAuthenticationTokens(string(user.Email), uuid.UUID(customerId))
if err != nil { if err != nil {
return nil, err return nil, err

View File

@@ -48,9 +48,3 @@ type User struct {
LastLogin interface{} LastLogin interface{}
CreatedAt sql.NullString CreatedAt sql.NullString
} }
type UserSession struct {
ID string
UserID string
CreatedAt string
}

View File

@@ -67,21 +67,6 @@ func (q *Queries) CreateCustomer(ctx context.Context, arg CreateCustomerParams)
return err return err
} }
const createNewSession = `-- name: CreateNewSession :exec
INSERT INTO user_sessions (id, user_id, created_at) VALUES (?, ?, ?)
`
type CreateNewSessionParams struct {
ID string
UserID string
CreatedAt string
}
func (q *Queries) CreateNewSession(ctx context.Context, arg CreateNewSessionParams) error {
_, err := q.db.ExecContext(ctx, createNewSession, arg.ID, arg.UserID, arg.CreatedAt)
return err
}
const createUser = `-- name: CreateUser :exec const createUser = `-- name: CreateUser :exec
INSERT INTO user ( INSERT INTO user (
id id
@@ -151,15 +136,6 @@ func (q *Queries) CreateUser(ctx context.Context, arg CreateUserParams) error {
return err return err
} }
const deleteSession = `-- name: DeleteSession :exec
DELETE FROM user_sessions WHERE id = ?
`
func (q *Queries) DeleteSession(ctx context.Context, id string) error {
_, err := q.db.ExecContext(ctx, deleteSession, id)
return err
}
const getCustomer = `-- name: GetCustomer :one const getCustomer = `-- name: GetCustomer :one
SELECT SELECT
max_nkode_len max_nkode_len
@@ -201,17 +177,6 @@ func (q *Queries) GetCustomer(ctx context.Context, id string) (GetCustomerRow, e
return i, err return i, err
} }
const getSession = `-- name: GetSession :one
SELECT id, user_id, created_at FROM user_sessions WHERE user_id = ?
`
func (q *Queries) GetSession(ctx context.Context, userID string) (UserSession, error) {
row := q.db.QueryRowContext(ctx, getSession, userID)
var i UserSession
err := row.Scan(&i.ID, &i.UserID, &i.CreatedAt)
return i, err
}
const getSvgCount = `-- name: GetSvgCount :one const getSvgCount = `-- name: GetSvgCount :one
SELECT COUNT(*) as count FROM svg_icon SELECT COUNT(*) as count FROM svg_icon
` `

View File

@@ -87,15 +87,6 @@ SET
,salt = ? ,salt = ?
WHERE id = ?; WHERE id = ?;
-- name: CreateNewSession :exec
INSERT INTO user_sessions (id, user_id, created_at) VALUES (?, ?, ?);
-- name: DeleteSession :exec
DELETE FROM user_sessions WHERE id = ?;
-- name: GetSession :one
SELECT id, user_id, created_at FROM user_sessions WHERE user_id = ?;
-- name: GetUserRenew :many -- name: GetUserRenew :many
SELECT SELECT
id id

View File

@@ -55,11 +55,3 @@ CREATE TABLE IF NOT EXISTS svg_icon (
id INTEGER PRIMARY KEY AUTOINCREMENT id INTEGER PRIMARY KEY AUTOINCREMENT
,svg TEXT NOT NULL ,svg TEXT NOT NULL
); );
CREATE TABLE IF NOT EXISTS user_sessions (
id TEXT PRIMARY KEY
,user_id TEXT NOT NULL UNIQUE
,created_at TEXT NOT NULL
,FOREIGN KEY (user_id) REFERENCES user(id)
);