2022-04-07 05:33:53 +00:00
|
|
|
package storage
|
|
|
|
|
|
|
|
import (
|
|
|
|
"database/sql"
|
|
|
|
|
|
|
|
"github.com/jmoiron/sqlx"
|
|
|
|
|
|
|
|
"github.com/authelia/authelia/v4/internal/model"
|
|
|
|
)
|
|
|
|
|
2022-10-20 02:16:36 +00:00
|
|
|
// ConsentPreConfigRows holds and assists with retrieving multiple model.OAuth2ConsentSession rows.
|
|
|
|
type ConsentPreConfigRows struct {
|
2022-04-07 05:33:53 +00:00
|
|
|
rows *sqlx.Rows
|
|
|
|
}
|
|
|
|
|
|
|
|
// Next is the row iterator.
|
2022-10-20 02:16:36 +00:00
|
|
|
func (r *ConsentPreConfigRows) Next() bool {
|
2022-04-07 05:33:53 +00:00
|
|
|
if r.rows == nil {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
|
|
|
return r.rows.Next()
|
|
|
|
}
|
|
|
|
|
|
|
|
// Close the rows.
|
2022-10-20 02:16:36 +00:00
|
|
|
func (r *ConsentPreConfigRows) Close() (err error) {
|
2022-04-07 05:33:53 +00:00
|
|
|
if r.rows == nil {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
return r.rows.Close()
|
|
|
|
}
|
|
|
|
|
|
|
|
// Get returns the *model.OAuth2ConsentSession or scan error.
|
2022-10-20 02:16:36 +00:00
|
|
|
func (r *ConsentPreConfigRows) Get() (config *model.OAuth2ConsentPreConfig, err error) {
|
2022-04-07 05:33:53 +00:00
|
|
|
if r.rows == nil {
|
|
|
|
return nil, sql.ErrNoRows
|
|
|
|
}
|
|
|
|
|
2022-10-20 02:16:36 +00:00
|
|
|
config = &model.OAuth2ConsentPreConfig{}
|
2022-04-07 05:33:53 +00:00
|
|
|
|
2022-10-20 02:16:36 +00:00
|
|
|
if err = r.rows.StructScan(config); err != nil {
|
2022-04-07 05:33:53 +00:00
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
2022-10-20 02:16:36 +00:00
|
|
|
return config, nil
|
2022-04-07 05:33:53 +00:00
|
|
|
}
|