File tree Expand file tree Collapse file tree 1 file changed +21
-0
lines changed
Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -225,6 +225,27 @@ func (a *API) UserUpdate(w http.ResponseWriter, r *http.Request) error {
225225 return terr
226226 }
227227
228+ if user .GetEmail () != "" {
229+ if _ , terr = models .FindIdentityByIdAndProvider (tx , user .ID .String (), "email" ); terr != nil {
230+ if ! models .IsNotFoundError (terr ) {
231+ return apierrors .NewInternalServerError ("Error finding email identity" ).WithInternalError (terr )
232+ }
233+ emailIdentity , terr := models .NewIdentity (user , "email" , map [string ]interface {}{
234+ "sub" : user .ID .String (),
235+ "email" : user .GetEmail (),
236+ })
237+ if terr != nil {
238+ return apierrors .NewInternalServerError ("Error creating email identity" ).WithInternalError (terr )
239+ }
240+ if terr := tx .Create (emailIdentity ); terr != nil {
241+ return apierrors .NewInternalServerError ("Error saving email identity" ).WithInternalError (terr )
242+ }
243+ if terr := user .UpdateAppMetaDataProviders (tx ); terr != nil {
244+ return apierrors .NewInternalServerError ("Error updating providers" ).WithInternalError (terr )
245+ }
246+ }
247+ }
248+
228249 // send a Password Changed email notification to the user to inform them that their password has been changed
229250 if config .Mailer .Notifications .PasswordChangedEnabled && user .GetEmail () != "" {
230251 if err := a .sendPasswordChangedNotification (r , tx , user ); err != nil {
You can’t perform that action at this time.
0 commit comments