mirror of
https://github.com/owncast/owncast.git
synced 2024-12-18 15:23:55 +03:00
2ccd3aad87
* It builds with the new user repository * fix(test): fix broken test * fix(api): fix registration endpoint that was broken after the change * fix(test): update test to reflect new user repository * fix: use interface type instead of concrete type * fix: restore commented out code
23 lines
607 B
Go
23 lines
607 B
Go
package auth
|
|
|
|
import (
|
|
"github.com/owncast/owncast/core/data"
|
|
)
|
|
|
|
var _datastore *data.Datastore
|
|
|
|
// Setup will initialize auth persistence.
|
|
func Setup(db *data.Datastore) {
|
|
_datastore = db
|
|
|
|
createTableSQL := `CREATE TABLE IF NOT EXISTS auth (
|
|
"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
|
|
"user_id" TEXT NOT NULL,
|
|
"token" TEXT NOT NULL,
|
|
"type" TEXT NOT NULL,
|
|
"timestamp" DATE DEFAULT CURRENT_TIMESTAMP NOT NULL,
|
|
FOREIGN KEY(user_id) REFERENCES users(id)
|
|
);`
|
|
_datastore.MustExec(createTableSQL)
|
|
_datastore.MustExec(`CREATE INDEX IF NOT EXISTS idx_auth_token ON auth (token);`)
|
|
}
|