Support Reminder events
Move code to schedule to have event independent from NotificationPlatform
This commit is contained in:
parent
04d1894aea
commit
80afab3bc0
7 changed files with 61 additions and 28 deletions
|
@ -216,7 +216,7 @@ func (h *Handler) thirdPartyAuthCallback(c *gin.Context) {
|
|||
// create a random password for the user using crypto/rand:
|
||||
password := auth.GenerateRandomPassword(12)
|
||||
encodedPassword, err := auth.EncodePassword(password)
|
||||
acc = &uModel.User{
|
||||
account := &uModel.User{
|
||||
Username: userinfo.Id,
|
||||
Email: userinfo.Email,
|
||||
Image: userinfo.Picture,
|
||||
|
@ -224,7 +224,7 @@ func (h *Handler) thirdPartyAuthCallback(c *gin.Context) {
|
|||
DisplayName: userinfo.GivenName,
|
||||
Provider: uModel.AuthProviderGoogle,
|
||||
}
|
||||
createdUser, err := h.userRepo.CreateUser(c, acc)
|
||||
createdUser, err := h.userRepo.CreateUser(c, account)
|
||||
if err != nil {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{
|
||||
"error": "Unable to create user",
|
||||
|
@ -316,14 +316,14 @@ func (h *Handler) thirdPartyAuthCallback(c *gin.Context) {
|
|||
c.JSON(http.StatusInternalServerError, gin.H{"error": "Password encoding failed"})
|
||||
return
|
||||
}
|
||||
acc = &uModel.User{
|
||||
account := &uModel.User{
|
||||
Username: claims.Email,
|
||||
Email: claims.Email,
|
||||
Password: encodedPassword,
|
||||
DisplayName: claims.DisplayName,
|
||||
Provider: uModel.AuthProviderOAuth2,
|
||||
}
|
||||
createdUser, err := h.userRepo.CreateUser(c, acc)
|
||||
createdUser, err := h.userRepo.CreateUser(c, account)
|
||||
if err != nil {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{
|
||||
"error": "Unable to create user",
|
||||
|
|
|
@ -75,9 +75,9 @@ func (r *UserRepository) UpdateUserCircle(c context.Context, userID, circleID in
|
|||
return r.db.WithContext(c).Model(&uModel.User{}).Where("id = ?", userID).Update("circle_id", circleID).Error
|
||||
}
|
||||
|
||||
func (r *UserRepository) FindByEmail(c context.Context, email string) (*uModel.User, error) {
|
||||
var user *uModel.User
|
||||
if err := r.db.WithContext(c).Where("email = ?", email).First(&user).Error; err != nil {
|
||||
func (r *UserRepository) FindByEmail(c context.Context, email string) (*uModel.UserDetails, error) {
|
||||
var user *uModel.UserDetails
|
||||
if err := r.db.WithContext(c).Table("users u").Select("u.*, c.webhook_url as webhook_url").Joins("left join circles c on c.id = u.circle_id").Where("email = ?", email).First(&user).Error; err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return user, nil
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue