Compare commits

...

5 Commits
salim ... main

Author SHA1 Message Date
Arnaud Delcasse de94bd583f fix sum 2023-11-27 09:03:37 +01:00
Arnaud Delcasse 3a80acae37 Fix issue with localauth conversion 2023-11-27 09:00:40 +01:00
Arnaud Delcasse 045bcb7bf6 Merge branch 'master' 2023-11-27 08:52:16 +01:00
Nicolas CARON 6f9d57c6d7 run go mod tidy 2023-08-21 14:58:18 +02:00
Arnaud Delcasse f5bb2e7c2c Fix issue in mongodb connection 2023-04-30 13:53:20 +02:00
3 changed files with 24 additions and 16 deletions

3
go.sum
View File

@ -790,6 +790,9 @@ github.com/nicksnyder/go-i18n v1.10.0/go.mod h1:HrK7VCrbOvQoUAQ7Vpy7i87N7JZZZ7R2
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e h1:fD57ERR4JtEqsWbfPhv4DMiApHyliiK5xCTNVSPiaAs= github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e h1:fD57ERR4JtEqsWbfPhv4DMiApHyliiK5xCTNVSPiaAs=
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno= github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno=
github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U= github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U=
github.com/oleiade/reflections v1.0.0/go.mod h1:rdFxbxq4QXVZWj0F+e9jqjDkc7dbp97vkRixKo2JR60=
github.com/oleiade/reflections v1.0.1 h1:D1XO3LVEYroYskEsoSiGItp9RUxG6jWnCVvrqH0HHQM=
github.com/oleiade/reflections v1.0.1/go.mod h1:rdFxbxq4QXVZWj0F+e9jqjDkc7dbp97vkRixKo2JR60=
github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
github.com/onsi/ginkgo v1.8.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.8.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=

View File

@ -38,19 +38,25 @@ func (a Account) ToStorageType() storage.Account {
} }
func (lc LocalAuth) ToStorageType() storage.LocalAuth { func (lc LocalAuth) ToStorageType() storage.LocalAuth {
emailValidation := storage.Validation{}
if lc.EmailValidation != nil {
emailValidation.Validated = lc.EmailValidation.Validated
emailValidation.ValidationCode = lc.EmailValidation.ValidationCode
}
phoneValidation := storage.Validation{}
if lc.PhoneNumberValidation != nil {
phoneValidation.Validated = lc.PhoneNumberValidation.Validated
phoneValidation.ValidationCode = lc.PhoneNumberValidation.ValidationCode
}
return storage.LocalAuth{ return storage.LocalAuth{
Username: lc.Username, Username: lc.Username,
Password: lc.Password, Password: lc.Password,
Email: lc.Email, Email: lc.Email,
EmailValidation: storage.Validation{ EmailValidation: emailValidation,
Validated: lc.EmailValidation.Validated, PhoneNumber: lc.PhoneNumber,
ValidationCode: lc.EmailValidation.ValidationCode, PhoneNumberValidation: phoneValidation,
},
PhoneNumber: lc.PhoneNumber,
PhoneNumberValidation: storage.Validation{
Validated: lc.PhoneNumberValidation.Validated,
ValidationCode: lc.PhoneNumberValidation.ValidationCode,
},
} }
} }

View File

@ -27,7 +27,7 @@ func NewMongoDBStorage(cfg *viper.Viper) (MongoDBStorage, error) {
) )
if mongodb_uri == "" { if mongodb_uri == "" {
mongodb_uri = fmt.Sprintf("mongodb://%s:%s/%s", mongodb_host, mongodb_port, mongodb_dbname) mongodb_uri = fmt.Sprintf("mongodb://%s:%s", mongodb_host, mongodb_port)
} }
client, err := mongo.NewClient(options.Client().ApplyURI(mongodb_uri)) client, err := mongo.NewClient(options.Client().ApplyURI(mongodb_uri))
@ -82,10 +82,9 @@ 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 { if err := collection.FindOne(context.TODO(), bson.M{"namespace": namespace, "authentication.local.phone_number": phone_number}).Decode(account); err != nil {
return nil, err 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 return account, nil
} }