-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
24 changed files
with
366 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,3 +5,4 @@ node_modules | |
.vscode | ||
.trunk | ||
.env.dev | ||
.env.prod |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package auth | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
|
||
"github.com/resend/resend-go/v2" | ||
) | ||
|
||
type EmailService struct { | ||
Client *resend.Client | ||
} | ||
|
||
func NewEmailService() *EmailService { | ||
client := resend.NewClient(os.Getenv("SAC_RESEND_API_KEY")) | ||
return &EmailService{ | ||
Client: client, | ||
} | ||
} | ||
|
||
func (e *EmailService) SendPasswordResetEmail(name, email, token string) error { | ||
params := &resend.SendEmailRequest{ | ||
From: "[email protected]", | ||
To: []string{"[email protected]"}, | ||
Subject: "Password Reset", | ||
Html: fmt.Sprintf("<p>Hello %s, <br> Forgot your password? you can reset your password by clicking on this link: <a href='https://sac.resend.dev/reset-password/%s'>Reset Password</a> You can also copy and paste the following link into your browser: https://sac.resend.dev/reset-password/%s <br><br> If you did not request a password reset, please ignore this email.</p>", name, token, token), | ||
} | ||
|
||
_, err := e.Client.Emails.Send(params) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package config | ||
|
||
import ( | ||
"errors" | ||
"os" | ||
|
||
m "github.com/garrettladley/mattress" | ||
) | ||
|
||
type ResendSettings struct { | ||
APIKey *m.Secret[string] | ||
} | ||
|
||
func readResendSettings() (*ResendSettings, error) { | ||
apiKey := os.Getenv("SAC_RESEND_API_KEY") | ||
if apiKey == "" { | ||
return nil, errors.New("SAC_RESEND_API_KEY is not set") | ||
} | ||
|
||
secretAPIKey, err := m.NewSecret(apiKey) | ||
if err != nil { | ||
return nil, errors.New("failed to create secret from api key") | ||
} | ||
|
||
return &ResendSettings{ | ||
APIKey: secretAPIKey, | ||
}, nil | ||
} | ||
Check failure on line 28 in backend/src/config/resend.go GitHub Actions / Lint
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package models | ||
|
||
import ( | ||
"time" | ||
|
||
"github.com/google/uuid" | ||
) | ||
|
||
type PasswordReset struct { | ||
UserID uuid.UUID `gorm:"type:varchar(36);not null;primaryKey" json:"user_id" validate:"required,uuid4"` | ||
Token string `gorm:"type:varchar(255);unique" json:"token" validate:"required,max=255"` | ||
ExpiresAt time.Time `gorm:"type:timestamp;not null;primaryKey" json:"expires_at" validate:"required"` | ||
} | ||
|
||
type PasswordResetRequestBody struct { | ||
Email string `json:"email" validate:"required,email"` | ||
} | ||
|
||
type VerifyPasswordResetTokenRequestBody struct { | ||
Token string `json:"token" validate:"required"` | ||
NewPassword string `json:"new_password" validate:"required,min=8,password"` | ||
VerifyNewPassword string `json:"verify_new_password" validate:"required,min=8,password,eqfield=NewPassword"` | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.