feat: use upsert for otp + implement otp methods for cassandradb

This commit is contained in:
Lakhan Samani
2022-07-23 16:39:35 +05:30
parent 22ae3bca54
commit f6029fb7bf
7 changed files with 86 additions and 82 deletions

View File

@@ -221,6 +221,17 @@ func NewProvider() (*provider, error) {
return nil, err
}
otpCollection := fmt.Sprintf("CREATE TABLE IF NOT EXISTS %s.%s (id text, email text, otp text, expires_at bigint, updated_at bigint, created_at bigint, PRIMARY KEY (id))", KeySpace, models.Collections.OTP)
err = session.Query(otpCollection).Exec()
if err != nil {
return nil, err
}
otpIndexQuery := fmt.Sprintf("CREATE INDEX IF NOT EXISTS authorizer_otp_email ON %s.%s (email)", KeySpace, models.Collections.OTP)
err = session.Query(otpIndexQuery).Exec()
if err != nil {
return nil, err
}
return &provider{
db: session,
}, err