maj du script avec des roles pour les users

This commit is contained in:
Guams 2024-12-25 20:33:48 +01:00
parent c3dd337c7d
commit 9fa9630e5d
2 changed files with 6 additions and 2 deletions

View File

@ -103,7 +103,8 @@ public class AuthorController {
throw new AlreadyExistsException("Author already exists"); throw new AlreadyExistsException("Author already exists");
} }
author.setPassword(passwordEncoder.encode(author.getPassword())); author.setPassword(passwordEncoder.encode(author.getPassword()));
return new ResponseEntity<>(authorRepository.save(author.setRole("USER")).setPassword(""), HttpStatus.CREATED); return new ResponseEntity<>(authorRepository.save(author.setRole("READER")).setPassword(""), HttpStatus.CREATED);
} }
@GetMapping(value = "/me", produces = "application/json") @GetMapping(value = "/me", produces = "application/json")

View File

@ -1,6 +1,9 @@
drop table if exists publication; drop table if exists publication;
drop table if exists post; drop table if exists post;
drop table if exists author; drop table if exists author;
drop type if exists author_role;
create type author_role as enum ('READER', 'WRITER', 'ADMIN');
create table author create table author
( (
@ -8,7 +11,7 @@ create table author
name varchar(255) unique not null, name varchar(255) unique not null,
password text not null, password text not null,
profile_picture bytea, profile_picture bytea,
role varchar(50) default 'USER' not null role author_role default 'READER' not null
); );
create table post create table post