Skip to content

Commit

Permalink
Merge main
Browse files Browse the repository at this point in the history
  • Loading branch information
Alder Whiteford authored and Alder Whiteford committed May 20, 2024
2 parents 52e67e5 + 1eb8554 commit e2846b7
Show file tree
Hide file tree
Showing 172 changed files with 8,653 additions and 10,637 deletions.
26 changes: 26 additions & 0 deletions .github/ISSUE_TEMPLATE/bug-report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
---
name: "☢️ Bug"
about: Create a report to help us improve
title: "☢️ bug: [Short description of the bug]"
labels: ["☢️ bug"]
---

**Describe the bug**
A clear and concise description of what the bug is.

**To Reproduce**
Steps to reproduce the behavior:

1. Go to '...'
2. Click on '...'
3. Scroll down to '...'
4. See error

**Expected behavior**
A clear and concise description of what you expected to happen.

**Screenshots**
If applicable, add screenshots to help explain your problem.

**Additional context**
Add any other context about the problem here.
18 changes: 18 additions & 0 deletions .github/ISSUE_TEMPLATE/chore.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
name: "🧹 Chore"
about: Something you'd like to see done but not urgently
title: "🧹 chore: [Short description of the chore]"
labels: ["🧹 chore"]
---

**Please describe.**
A clear and concise description of what you'd like to see. Ex. We should [...]

**Describe the solution you'd like**
A clear and concise description of what you want to happen.

**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.

**Additional context**
Add any other context or screenshots about the feature request here.
18 changes: 18 additions & 0 deletions .github/ISSUE_TEMPLATE/feature-request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
name: "📝 Feature Request"
about: Suggest an idea for this project
title: "📝 feat: [Short description of the feature]"
labels: ["📝 feature"]
---

**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

**Describe the solution you'd like**
A clear and concise description of what you want to happen.

**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.

**Additional context**
Add any other context or screenshots about the feature request here.
13 changes: 10 additions & 3 deletions backend/auth/password.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package auth

import (
"errors"
"fmt"
"regexp"
"strings"
Expand All @@ -9,16 +10,22 @@ import (
)

func ValidatePassword(password string) error {
var errs []string

if len(password) < 8 {
return fmt.Errorf("password must be at least 8 characters long")
errs = append(errs, "must be at least 8 characters long")
}

if !hasDigit(password) {
return fmt.Errorf("password must contain at least one digit")
errs = append(errs, "must contain at least one digit")
}

if !hasSpecialChar(password) {
return fmt.Errorf("password must contain at least one special character")
errs = append(errs, fmt.Sprintf("must contain at least one special character from: [%v]", string(constants.SPECIAL_CHARACTERS)))
}

if len(errs) > 0 {
return errors.New(strings.Join(errs, ", "))
}

return nil
Expand Down
24 changes: 24 additions & 0 deletions backend/config/calendar.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package config

import (
"time"
)

type CalendarSettings struct {
MaxTerminationDate time.Time
}

type intermediateCalendarSettings struct {
MaxTerminationDate string `yaml:"maxterminationdate"`
}

func (int *intermediateCalendarSettings) into() (*CalendarSettings, error) {
t, err := time.Parse("01-02-2006", int.MaxTerminationDate)
if err != nil {
return nil, err
}

return &CalendarSettings{
MaxTerminationDate: t,
}, nil
}
24 changes: 16 additions & 8 deletions backend/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,15 @@ import (
)

type Settings struct {
Application ApplicationSettings
Database DatabaseSettings
SuperUser SuperUserSettings
Auth AuthSettings
AWS AWSSettings
PineconeSettings PineconeSettings
OpenAISettings OpenAISettings
ResendSettings ResendSettings
Application ApplicationSettings
Database DatabaseSettings
SuperUser SuperUserSettings
Auth AuthSettings
AWS AWSSettings
Pinecone PineconeSettings
OpenAI OpenAISettings
Resend ResendSettings
Calendar CalendarSettings
GoogleClientSettings *OAuthConfig
OutlookClientSettings *OAuthConfig
}
Expand All @@ -25,6 +26,7 @@ type intermediateSettings struct {
Database intermediateDatabaseSettings `yaml:"database"`
SuperUser intermediateSuperUserSettings `yaml:"superuser"`
Auth intermediateAuthSettings `yaml:"authsecret"`
Calendar intermediateCalendarSettings `yaml:"calendar"`
}

func (int *intermediateSettings) into() (*Settings, error) {
Expand All @@ -43,11 +45,17 @@ func (int *intermediateSettings) into() (*Settings, error) {
return nil, err
}

calendarSettings, err := int.Calendar.into()
if err != nil {
return nil, err
}

return &Settings{
Application: int.Application,
Database: *databaseSettings,
SuperUser: *superUserSettings,
Auth: *authSettings,
Calendar: *calendarSettings,
}, nil
}

Expand Down
6 changes: 3 additions & 3 deletions backend/config/local.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,14 @@ func readLocal(v *viper.Viper, path string, useDevDotEnv bool) (*Settings, error
return nil, fmt.Errorf("failed to read Pinecone settings: %w", err)
}

settings.PineconeSettings = *pineconeSettings
settings.Pinecone = *pineconeSettings

openAISettings, err := readOpenAISettings()
if err != nil {
return nil, fmt.Errorf("failed to read OpenAI settings: %w", err)
}

settings.OpenAISettings = *openAISettings
settings.OpenAI = *openAISettings

awsSettings, err := readAWSSettings()
if err != nil {
Expand All @@ -64,7 +64,7 @@ func readLocal(v *viper.Viper, path string, useDevDotEnv bool) (*Settings, error
return nil, fmt.Errorf("failed to read Resend settings: %w", err)
}

settings.ResendSettings = *resendSettings
settings.Resend = *resendSettings

googleSettings, err := readGoogleOAuthSettings()
if err != nil {
Expand Down
10 changes: 6 additions & 4 deletions backend/config/production.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
type ProductionSettings struct {
Database ProductionDatabaseSettings `yaml:"database"`
Application ProductionApplicationSettings `yaml:"application"`
Calendar CalendarSettings `yaml:"calendar"`
}

type ProductionDatabaseSettings struct {
Expand Down Expand Up @@ -134,11 +135,12 @@ func readProd(v *viper.Viper) (*Settings, error) {
RefreshKey: authRefreshKey,
CSRFKey: authCSRFKey,
},
PineconeSettings: *pineconeSettings,
OpenAISettings: *openAISettings,
AWS: *awsSettings,
ResendSettings: *resendSettings,
Pinecone: *pineconeSettings,
OpenAI: *openAISettings,
AWS: *awsSettings,
Resend: *resendSettings,
GoogleClientSettings: googleSettings,
OutlookClientSettings: outlookSettings,
Calendar: prodSettings.Calendar,
}, nil
}
7 changes: 6 additions & 1 deletion backend/database/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,11 @@ func CreateSuperUserIfNotExists(settings config.Settings, db *gorm.DB) error {

func createSuperUser(settings config.Settings, db *gorm.DB) error {
tx := db.Begin()
defer func() {
if r := recover(); r != nil {
tx.Rollback()
}
}()

if err := tx.Error; err != nil {
return err
Expand Down Expand Up @@ -144,5 +149,5 @@ func createSuperUser(settings config.Settings, db *gorm.DB) error {
return tx.Commit().Error
}

return nil
return tx.Commit().Error
}
Loading

0 comments on commit e2846b7

Please sign in to comment.