Revert "Adminbereich mit Rollen und Nutzerauswertung ergänzen"
This reverts commit e432943ea7.
This commit is contained in:
@@ -142,9 +142,9 @@ func (s *PostgresStore) CreateUser(ctx context.Context, email, passwordHash, uiL
|
||||
row := s.db.QueryRowContext(ctx, `
|
||||
INSERT INTO users (id, email, password_hash, ui_language)
|
||||
VALUES ($1, $2, $3, $4)
|
||||
RETURNING id, email, ui_language, role, created_at
|
||||
RETURNING id, email, ui_language, created_at
|
||||
`, user.ID, user.Email, passwordHash, uiLanguage)
|
||||
if err := row.Scan(&user.ID, &user.Email, &user.UILanguage, &user.Role, &user.CreatedAt); err != nil {
|
||||
if err := row.Scan(&user.ID, &user.Email, &user.UILanguage, &user.CreatedAt); err != nil {
|
||||
return domain.User{}, err
|
||||
}
|
||||
return user, nil
|
||||
@@ -154,11 +154,11 @@ func (s *PostgresStore) GetPasswordHashByEmail(ctx context.Context, email string
|
||||
var user domain.User
|
||||
var hash string
|
||||
row := s.db.QueryRowContext(ctx, `
|
||||
SELECT id, email, password_hash, ui_language, role, created_at
|
||||
SELECT id, email, password_hash, ui_language, created_at
|
||||
FROM users
|
||||
WHERE email = $1
|
||||
`, strings.ToLower(strings.TrimSpace(email)))
|
||||
if err := row.Scan(&user.ID, &user.Email, &hash, &user.UILanguage, &user.Role, &user.CreatedAt); err != nil {
|
||||
if err := row.Scan(&user.ID, &user.Email, &hash, &user.UILanguage, &user.CreatedAt); err != nil {
|
||||
if errors.Is(err, sql.ErrNoRows) {
|
||||
return domain.User{}, "", ErrNotFound
|
||||
}
|
||||
@@ -170,11 +170,11 @@ func (s *PostgresStore) GetPasswordHashByEmail(ctx context.Context, email string
|
||||
func (s *PostgresStore) GetUser(ctx context.Context, id string) (domain.User, error) {
|
||||
var user domain.User
|
||||
row := s.db.QueryRowContext(ctx, `
|
||||
SELECT id, email, ui_language, role, created_at
|
||||
SELECT id, email, ui_language, created_at
|
||||
FROM users
|
||||
WHERE id = $1
|
||||
`, id)
|
||||
if err := row.Scan(&user.ID, &user.Email, &user.UILanguage, &user.Role, &user.CreatedAt); err != nil {
|
||||
if err := row.Scan(&user.ID, &user.Email, &user.UILanguage, &user.CreatedAt); err != nil {
|
||||
if errors.Is(err, sql.ErrNoRows) {
|
||||
return domain.User{}, ErrNotFound
|
||||
}
|
||||
@@ -558,11 +558,6 @@ CREATE TABLE IF NOT EXISTS users (
|
||||
created_at TIMESTAMPTZ NOT NULL DEFAULT now()
|
||||
);
|
||||
|
||||
-- Existing installations receive the role on startup; public registration
|
||||
-- continues to create only learner accounts.
|
||||
ALTER TABLE users ADD COLUMN IF NOT EXISTS role TEXT NOT NULL DEFAULT 'learner'
|
||||
CHECK (role IN ('learner', 'admin'));
|
||||
|
||||
CREATE TABLE IF NOT EXISTS learner_profiles (
|
||||
id TEXT PRIMARY KEY,
|
||||
user_id TEXT NOT NULL REFERENCES users(id) ON DELETE CASCADE,
|
||||
|
||||
Reference in New Issue
Block a user