Previous version of Tanabata used as visual and functional reference for the new Go + SvelteKit rewrite. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
17 lines
484 B
Go
17 lines
484 B
Go
package postgres
|
|
|
|
import "context"
|
|
|
|
func UserLogin(ctx context.Context, name, password string) (user_id int, err error) {
|
|
row := connPool.QueryRow(ctx, "SELECT id FROM users WHERE name=$1 AND password=crypt($2, password)", name, password)
|
|
err = row.Scan(&user_id)
|
|
return
|
|
}
|
|
|
|
func UserAuth(ctx context.Context, user_id int) (ok, isAdmin bool) {
|
|
row := connPool.QueryRow(ctx, "SELECT is_admin FROM users WHERE id=$1", user_id)
|
|
err := row.Scan(&isAdmin)
|
|
ok = (err == nil)
|
|
return
|
|
}
|