mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-09-22 13:39:35 +00:00
resolved review concerns
This commit is contained in:
@@ -37,13 +37,17 @@ func WriteInitalConfig(userCredentials *models.UserCredentials) error {
|
||||
Email: userCredentials.Email,
|
||||
Domain: config.INFISICAL_URL,
|
||||
}
|
||||
if len(existingConfigFile.LoggedInUsers) > 0 {
|
||||
ok := ConfigContainsEmail(existingConfigFile.LoggedInUsers, userCredentials.Email)
|
||||
if !ok {
|
||||
existingConfigFile.LoggedInUsers = append(existingConfigFile.LoggedInUsers, loggedInUser)
|
||||
}
|
||||
} else {
|
||||
//if empty or if email not in loggedinUsers
|
||||
if len(existingConfigFile.LoggedInUsers) == 0 || !ConfigContainsEmail(existingConfigFile.LoggedInUsers, userCredentials.Email) {
|
||||
|
||||
existingConfigFile.LoggedInUsers = append(existingConfigFile.LoggedInUsers, loggedInUser)
|
||||
} else {
|
||||
//if exists update domain of loggedin users
|
||||
for idx, user := range existingConfigFile.LoggedInUsers {
|
||||
if user.Email == userCredentials.Email {
|
||||
existingConfigFile.LoggedInUsers[idx] = loggedInUser
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
configFile := models.ConfigFile{
|
||||
|
||||
@@ -63,9 +63,10 @@ func IsSecretTypeValid(s string) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func ConfigContainsEmail(iter []models.LoggedInUser, elem string) bool {
|
||||
for _, value := range iter {
|
||||
if value.Email == elem {
|
||||
// Checks if the passed in email already exists in the users slice
|
||||
func ConfigContainsEmail(users []models.LoggedInUser, email string) bool {
|
||||
for _, value := range users {
|
||||
if value.Email == email {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user