Improvements for RIDYGO
This commit is contained in:
@@ -43,7 +43,16 @@ func NewMongoDBStorage(cfg *viper.Viper) (MongoDBStorage, error) {
|
||||
"users": mongodb_users,
|
||||
},
|
||||
}
|
||||
//TODO Indexes
|
||||
|
||||
// usernameIndex := mongo.IndexModel{
|
||||
// Keys: bson.D{
|
||||
// {"namespace", 1},
|
||||
// {"authentication.local.username", 1},
|
||||
// },
|
||||
// Options: options.Index().SetUnique(true),
|
||||
// }
|
||||
// storage.Client.Database(mongodb_dbname).Collection(mongodb_users).Indexes().CreateOne(context.TODO(), usernameIndex)
|
||||
|
||||
return storage, err
|
||||
}
|
||||
|
||||
@@ -68,9 +77,10 @@ func (s MongoDBStorage) LocalAuthentication(namespace string, username string, e
|
||||
if err := collection.FindOne(context.TODO(), bson.M{"namespace": namespace, "authentication.local.phone_number": phone_number}).Decode(account); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
} else {
|
||||
return nil, errors.New("missing username, email or password")
|
||||
}
|
||||
// else {
|
||||
// return nil, errors.New("missing username, email or password")
|
||||
// }
|
||||
|
||||
return account, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user