File tree Expand file tree Collapse file tree 1 file changed +5
-14
lines changed
backend/internal/entity/user Expand file tree Collapse file tree 1 file changed +5
-14
lines changed Original file line number Diff line number Diff line change @@ -61,19 +61,6 @@ func (m *Model) LoadByEmail(email string) error {
61
61
return result .Error
62
62
}
63
63
64
- /*
65
- // Touch will update model's timestamp(s)
66
- func (m *Model) Touch(created bool) {
67
- var d types.DBDate
68
- d.Time = time.Now()
69
- if created {
70
- m.CreatedOn = d
71
- }
72
- m.ModifiedOn = d
73
- m.generateGravatar()
74
- }
75
- */
76
-
77
64
// Save will save this model to the DB
78
65
func (m * Model ) Save () error {
79
66
// Ensure email is nice
@@ -82,8 +69,12 @@ func (m *Model) Save() error {
82
69
return errors .ErrSystemUserReadonly
83
70
}
84
71
72
+ // Check if an existing user with this email exists
73
+ if m2 , err := GetByEmail (m .Email ); err == nil && m .ID != m2 .ID {
74
+ return errors .ErrDuplicateEmailUser
75
+ }
76
+
85
77
db := database .GetDB ()
86
- // todo: touch? not sure that save does this or not?
87
78
result := db .Save (m )
88
79
return result .Error
89
80
}
You can’t perform that action at this time.
0 commit comments