-
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
1 parent
6e25748
commit 124faac
Showing
6 changed files
with
185 additions
and
74 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
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 |
---|---|---|
@@ -1,7 +1,6 @@ | ||
package database | ||
|
||
import ( | ||
"github.com/GenerateNU/sac/backend/src/auth" | ||
"github.com/GenerateNU/sac/backend/src/config" | ||
"github.com/GenerateNU/sac/backend/src/models" | ||
|
||
|
@@ -78,22 +77,12 @@ func createSuperUser(settings config.Settings, db *gorm.DB) error { | |
return err | ||
} | ||
|
||
passwordHash, err := auth.ComputePasswordHash(settings.SuperUser.Password) | ||
superUser, err := SuperUser(settings.SuperUser) | ||
if err != nil { | ||
tx.Rollback() | ||
return err | ||
} | ||
|
||
superUser := models.User{ | ||
Role: models.Super, | ||
NUID: "000000000", | ||
Email: "[email protected]", | ||
PasswordHash: *passwordHash, | ||
FirstName: "SAC", | ||
LastName: "Super", | ||
College: models.KCCS, | ||
Year: models.First, | ||
} | ||
|
||
var user models.User | ||
|
||
if err := db.Where("nuid = ?", superUser.NUID).First(&user).Error; err != nil { | ||
|
@@ -108,17 +97,7 @@ func createSuperUser(settings config.Settings, db *gorm.DB) error { | |
return err | ||
} | ||
|
||
superClub := models.Club{ | ||
Name: "SAC", | ||
Preview: "SAC", | ||
Description: "SAC", | ||
NumMembers: 0, | ||
IsRecruiting: true, | ||
RecruitmentCycle: models.RecruitmentCycle(models.Always), | ||
RecruitmentType: models.Application, | ||
ApplicationLink: "https://generatenu.com/apply", | ||
Logo: "https://aws.amazon.com/s3", | ||
} | ||
superClub := SuperClub() | ||
|
||
if err := tx.Create(&superClub).Error; err != nil { | ||
tx.Rollback() | ||
|
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,40 @@ | ||
package database | ||
|
||
import ( | ||
"github.com/GenerateNU/sac/backend/src/auth" | ||
"github.com/GenerateNU/sac/backend/src/config" | ||
"github.com/GenerateNU/sac/backend/src/errors" | ||
"github.com/GenerateNU/sac/backend/src/models" | ||
) | ||
|
||
func SuperUser(superUserSettings config.SuperUserSettings) (*models.User, *errors.Error) { | ||
passwordHash, err := auth.ComputePasswordHash(superUserSettings.Password) | ||
if err != nil { | ||
return nil, &errors.FailedToComputePasswordHash | ||
} | ||
|
||
return &models.User{ | ||
Role: models.Super, | ||
NUID: "000000000", | ||
Email: "[email protected]", | ||
PasswordHash: *passwordHash, | ||
FirstName: "SAC", | ||
LastName: "Super", | ||
College: models.KCCS, | ||
Year: models.First, | ||
}, nil | ||
} | ||
|
||
func SuperClub() models.Club { | ||
return models.Club{ | ||
Name: "SAC", | ||
Preview: "SAC", | ||
Description: "SAC", | ||
NumMembers: 0, | ||
IsRecruiting: true, | ||
RecruitmentCycle: models.RecruitmentCycle(models.Always), | ||
RecruitmentType: models.Application, | ||
ApplicationLink: "https://generatenu.com/apply", | ||
Logo: "https://aws.amazon.com/s3", | ||
} | ||
} |
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