-
Notifications
You must be signed in to change notification settings - Fork 0
feature/change-user-entity-add-dev-user #17
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
Changes from all commits
9855a18
50fc9c8
8c4da1e
072a720
a0fd1b9
95defb7
36be9e7
22bd5fc
4d750ff
34b9d49
ab05d20
220b547
6715a1c
b0459bf
a8f2da3
a1cf28b
7e3d189
64d93b1
86f5b9d
fcc43de
04b2c9a
2f2c0b8
f4368b8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,6 +4,7 @@ | |
| import jakarta.persistence.Entity; | ||
| import jakarta.persistence.Id; | ||
| import jakarta.persistence.Table; | ||
| import org.jspecify.annotations.Nullable; | ||
| import org.springframework.security.web.webauthn.api.Bytes; | ||
| import org.springframework.security.web.webauthn.api.PublicKeyCredentialUserEntity; | ||
|
|
||
|
|
@@ -18,9 +19,15 @@ public class UserEntity implements PublicKeyCredentialUserEntity { | |
| private String id; | ||
|
|
||
| @Column(name = "name", nullable = false, unique = true) | ||
| private String email; | ||
| private String name; | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
|
|
||
| @Column(name = "display_name") | ||
| private String displayName; | ||
|
|
||
| @Column(name = "email") | ||
| private String email; | ||
|
Comment on lines
+27
to
+28
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Email is still treated as unique elsewhere, but this model no longer enforces it.
🤖 Prompt for AI Agents |
||
|
|
||
| @Column(name = "first_name") | ||
| private String firstName; | ||
|
|
||
| @Column(name = "last_name") | ||
|
|
@@ -41,10 +48,10 @@ public class UserEntity implements PublicKeyCredentialUserEntity { | |
| public UserEntity() { | ||
| } | ||
|
|
||
| public UserEntity(Bytes id, String email, String firstName) { | ||
| public UserEntity(Bytes id, String name, String displayName) { | ||
| this.id = id != null ? id.toBase64UrlString() : null; | ||
| this.email = email; | ||
| this.firstName = firstName; | ||
| this.name = name; | ||
| this.displayName = displayName; | ||
| } | ||
|
|
||
| @Override | ||
|
|
@@ -58,14 +65,21 @@ public void setId(Bytes id) { | |
|
|
||
| @Override | ||
| public String getName() { | ||
| return this.email; | ||
| return name; | ||
| } | ||
|
|
||
| public void setName(String name) { | ||
| this.name = name; | ||
| } | ||
|
|
||
| @Override | ||
| public String getDisplayName() { | ||
| return (this.firstName != null ? this.firstName : "") + " " + (this.lastName != null ? this.lastName : ""); | ||
| public @Nullable String getDisplayName() { | ||
| return displayName; | ||
| } | ||
|
|
||
| public void setDisplayName(String displayName) { | ||
| this.displayName = displayName; | ||
| } | ||
|
|
||
|
|
||
| public LocalDateTime getCreatedAt() { | ||
| return createdAt; | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,10 +1,14 @@ | ||
| package backendlab.team4you.user; | ||
|
|
||
|
|
||
| import org.springframework.data.jpa.repository.JpaRepository; | ||
| import org.springframework.stereotype.Repository; | ||
|
|
||
| import java.util.Optional; | ||
|
|
||
| @Repository | ||
| public interface UserRepository extends JpaRepository<UserEntity, String> { | ||
| Optional<UserEntity> findByEmail(String email); | ||
| } | ||
|
|
||
| Optional<UserEntity> findByName(String name); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Avoid hardcoding a known admin password in source control.
@Profile("dev")helps, but this still creates a predictableADMINcredential if the profile is enabled in the wrong environment or a shared dev stack. Read the password from environment/config, or generate it at startup instead of committing"123456".🤖 Prompt for AI Agents