diff --git a/api/nkode_api.go b/api/nkode_api.go index 9c80a90..655557c 100644 --- a/api/nkode_api.go +++ b/api/nkode_api.go @@ -189,6 +189,7 @@ func (n *NKodeAPI) Login(customerId entities.CustomerId, userEmail entities.User return nil, err } } + jwtToken, err := security.NewAuthenticationTokens(string(user.Email), uuid.UUID(customerId)) if err != nil { return nil, err diff --git a/sqlc/models.go b/sqlc/models.go index a965e77..d8f68cf 100644 --- a/sqlc/models.go +++ b/sqlc/models.go @@ -48,9 +48,3 @@ type User struct { LastLogin interface{} CreatedAt sql.NullString } - -type UserSession struct { - ID string - UserID string - CreatedAt string -} diff --git a/sqlc/query.sql.go b/sqlc/query.sql.go index 47fc8c0..c5956f8 100644 --- a/sqlc/query.sql.go +++ b/sqlc/query.sql.go @@ -67,21 +67,6 @@ func (q *Queries) CreateCustomer(ctx context.Context, arg CreateCustomerParams) 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 INSERT INTO user ( id @@ -151,15 +136,6 @@ func (q *Queries) CreateUser(ctx context.Context, arg CreateUserParams) error { 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 SELECT max_nkode_len @@ -201,17 +177,6 @@ func (q *Queries) GetCustomer(ctx context.Context, id string) (GetCustomerRow, e 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 SELECT COUNT(*) as count FROM svg_icon ` diff --git a/sqlite/query.sql b/sqlite/query.sql index 735ee50..abc7e7c 100644 --- a/sqlite/query.sql +++ b/sqlite/query.sql @@ -87,15 +87,6 @@ SET ,salt = ? 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 SELECT id diff --git a/sqlite/schema.sql b/sqlite/schema.sql index 55ea45e..4e30249 100644 --- a/sqlite/schema.sql +++ b/sqlite/schema.sql @@ -55,11 +55,3 @@ CREATE TABLE IF NOT EXISTS svg_icon ( id INTEGER PRIMARY KEY AUTOINCREMENT ,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) -);