auth + creating identities
This commit is contained in:
@@ -4,6 +4,7 @@ import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"libshared"
|
||||
"log"
|
||||
"net/http"
|
||||
"time"
|
||||
@@ -73,7 +74,7 @@ func createLocalHandler(w http.ResponseWriter, r *http.Request) {
|
||||
log.Println("Received Identity Request: AccountID:", accountid, "Username:", req.Username, "Password:", req.Password, "First Name:", req.FirstName, "LastName:", req.LastName)
|
||||
|
||||
// Check if policy with the same name already exists for the account
|
||||
checkExisting = pool.QueryRow(context.Background(),
|
||||
checkExisting = libshared.Pool.QueryRow(context.Background(),
|
||||
"SELECT FROM identities WHERE accountid = $1 AND provider_user_id = $2",
|
||||
accountid, req.Username)
|
||||
err = checkExisting.Scan()
|
||||
@@ -87,7 +88,7 @@ func createLocalHandler(w http.ResponseWriter, r *http.Request) {
|
||||
salt, _ = generateSalt()
|
||||
hashText = hashPassword(req.Password, salt)
|
||||
|
||||
_, err = pool.Exec(context.Background(),
|
||||
_, err = libshared.Pool.Exec(context.Background(),
|
||||
"INSERT INTO identities (accountid, provider, provider_user_id, password_hash) VALUES($1, $2, $3, $4) ON CONFLICT DO NOTHING",
|
||||
accountid, "local", req.Username, hashText)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user