Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add create profile check #3

Merged
merged 1 commit into from
Jan 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import com.github.gribanoveu.cuddle.entities.services.EmailService;
import com.github.gribanoveu.cuddle.entities.services.UserService;
import com.github.gribanoveu.cuddle.entities.tables.User;
import com.github.gribanoveu.cuddle.exeptions.CredentialEx;
import com.github.gribanoveu.cuddle.utils.emails.EmailTemplates;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
Expand All @@ -27,7 +28,8 @@ public class UserControllerImpl {

public ResponseEntity<User> getUserData(Authentication authentication) {
var userData = userService.findUserByEmail(authentication.getName());
return ResponseEntity.ok(userData);
if (userData.getProfileCreated()) return ResponseEntity.ok(userData);
throw new CredentialEx(ResponseCode.PROFILE_NOT_CREATED);
}

public ResponseEntity<StatusResponse> deleteUser(Authentication authentication) {
Expand All @@ -36,5 +38,4 @@ public ResponseEntity<StatusResponse> deleteUser(Authentication authentication)
EmailMessages.deleteSubject, EmailMessages.deleteSelfTemplate));
return ResponseEntity.ok(StatusResponse.create(ResponseCode.USER_DELETED, StatusLevel.SUCCESS));
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ public enum ResponseCode {
),
UNAUTHORIZED(
"AUT-102",
"Несанкционированный доступ",
"Требуется авторизация. Войдите в свою учетную запись, чтобы получить доступ к этой странице. Если вы забыли свои учетные данные, воспользуйтесь функцией восстановления пароля",
"Требуется авторизация",
"Войдите в свою учетную запись, чтобы получить доступ к этой странице. Если вы забыли свои учетные данные, воспользуйтесь функцией восстановления пароля",
HttpStatus.UNAUTHORIZED
),
BAD_CREDENTIAL(
Expand Down Expand Up @@ -83,6 +83,12 @@ public enum ResponseCode {
"На вашей учетной записи нет никаких ограничений",
HttpStatus.NOT_FOUND
),
PROFILE_NOT_CREATED(
"AUT-112",
"Создать профиль",
"Для продолжения требуется заполнить профиль",
HttpStatus.NOT_FOUND
),
PASSWORD_UPDATED(
"AUT-200",
"Пароль обновлен",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ public class User {
@Column(name = "role")
private Role role;

@Column(name = "profile_created")
private Boolean profileCreated;

@Column(name = "account_non_expired")
private Boolean accountNonExpired = true;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ALTER TABLE users ADD profile_created BOOLEAN NOT NULL default false;