More work on getting auth fetch verification working
This commit is contained in:
parent
7eac1db475
commit
9957ba8302
12 changed files with 434 additions and 205 deletions
|
@ -1505,6 +1505,7 @@ type IUserDo interface {
|
|||
GetPagedAllDeleted(pageNr uint) (result []models.User, err error)
|
||||
GetPagedAllNonDeleted(pageNr uint) (result []models.User, err error)
|
||||
GdprUsers() (err error)
|
||||
GetRemoteAccountByApUrl(url string) (result *models.User, err error)
|
||||
}
|
||||
|
||||
// Get a user by a username, ignoring all restrictions on that user
|
||||
|
@ -1636,6 +1637,30 @@ func (u userDo) GdprUsers() (err error) {
|
|||
return
|
||||
}
|
||||
|
||||
// Get user by AP url
|
||||
//
|
||||
// SELECT * FROM @@table
|
||||
//
|
||||
// WHERE id in (
|
||||
// SELECT user_id FROM user_remote_links
|
||||
// WHERE ap_link = @url LIMIT 1
|
||||
// )
|
||||
//
|
||||
// LIMIT 1
|
||||
func (u userDo) GetRemoteAccountByApUrl(url string) (result *models.User, err error) {
|
||||
var params []interface{}
|
||||
|
||||
var generateSQL strings.Builder
|
||||
params = append(params, url)
|
||||
generateSQL.WriteString("SELECT * FROM users WHERE id in ( SELECT user_id FROM user_remote_links WHERE ap_link = ? LIMIT 1 ) LIMIT 1 ")
|
||||
|
||||
var executeSQL *gorm.DB
|
||||
executeSQL = u.UnderlyingDB().Raw(generateSQL.String(), params...).Take(&result) // ignore_security_alert
|
||||
err = executeSQL.Error
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
func (u userDo) Debug() IUserDo {
|
||||
return u.withDO(u.DO.Debug())
|
||||
}
|
||||
|
|
|
@ -136,4 +136,14 @@ type IUser interface {
|
|||
//
|
||||
// DELETE FROM @@table WHERE deleted_at IS NOT NULL AND deleted_at + interval '30 days' < NOW()
|
||||
GdprUsers() error
|
||||
|
||||
// Get user by AP url
|
||||
//
|
||||
// SELECT * FROM @@table
|
||||
// WHERE id in (
|
||||
// SELECT user_id FROM user_remote_links
|
||||
// WHERE ap_link = @url LIMIT 1
|
||||
// )
|
||||
// LIMIT 1
|
||||
GetRemoteAccountByApUrl(url string) (*gen.T, error)
|
||||
}
|
||||
|
|
|
@ -14,6 +14,10 @@ import (
|
|||
"git.mstar.dev/mstar/linstrom/storage-new/models"
|
||||
)
|
||||
|
||||
// ID of the server actor account in the db.
|
||||
// Set by InsertSelf
|
||||
var ServerActorId = ""
|
||||
|
||||
func InsertSelf() error {
|
||||
if err := insertRoles(); err != nil {
|
||||
return other.Error("storage", "failed to save/update default roles", err)
|
||||
|
@ -30,6 +34,7 @@ func InsertSelf() error {
|
|||
if err != nil {
|
||||
return other.Error("storage", "failed to save/update self user", err)
|
||||
}
|
||||
ServerActorId = user.ID
|
||||
if err = insertUserPronoun(user); err != nil {
|
||||
return other.Error("storage", "failed to save/update self user pronoun", err)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue