- golem15_user_backend_links (1:1, both sides unique) and one-shot hashed
golem15_user_backend_link_requests (golem15.user.backend_links.request_ttl, 10m)
- classes.BackendLinks: CreateLinkRequest, ConfirmLinkRequest (row lock,
JWT iat not before the request), SetLink, RemoveLink, LinkedBackendUser;
published as *classes.BackendLinks and pact.MCPLinkedBackendResolver
- GET /_user/api/v1/backend-link/{code} and POST /backend-link/confirm (jwt.auth)
- My account section frontend_account with link and unlink
- BackendLinkedEvent, BackendUnlinkedEvent and pact.MCPSubjectChanged after commit;
deleting or deactivating a frontend user removes its link
- golem15.user.frontend_url (falls back to app.url)
25 lines
907 B
Go
25 lines
907 B
Go
package models
|
|
|
|
import "time"
|
|
|
|
// BackendLink is the verified link between one frontend user and one backend
|
|
// administrator (golem15_user_backend_links). Each side appears in at most
|
|
// one link. LinkedBy is the administrator who set the link on the
|
|
// Administrators screen; it is nil for a link the frontend user confirmed
|
|
// themselves after the administrator started it on My account.
|
|
type BackendLink struct {
|
|
ID uint `gorm:"column:id;primaryKey"`
|
|
UserID uint `gorm:"column:user_id"`
|
|
BackendUserID uint `gorm:"column:backend_user_id"`
|
|
LinkedBy *uint `gorm:"column:linked_by"`
|
|
CreatedAt time.Time `gorm:"column:created_at"`
|
|
}
|
|
|
|
func (BackendLink) TableName() string { return "golem15_user_backend_links" }
|
|
|
|
func (BackendLink) Fillable() []string {
|
|
return []string{"user_id", "backend_user_id", "linked_by"}
|
|
}
|
|
|
|
func init() { Register(BackendLink{}) }
|