mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-08-01 17:38:33 +00:00
added user creation from ap
This commit is contained in:
parent
a702da69cc
commit
e180467760
4 changed files with 107 additions and 16 deletions
|
@ -4,28 +4,21 @@
|
|||
package user
|
||||
|
||||
import (
|
||||
"code.gitea.io/gitea/models/db"
|
||||
"code.gitea.io/gitea/modules/validation"
|
||||
)
|
||||
|
||||
func init() {
|
||||
db.RegisterModel(new(FederatedUser))
|
||||
}
|
||||
|
||||
type FederatedUser struct {
|
||||
ID int64 `xorm:"pk NOT NULL"`
|
||||
UserID int64 `xorm:"NOT NULL"`
|
||||
ExternalID string `xorm:"TEXT UNIQUE(federation_mapping) NOT NULL"`
|
||||
FederationHostID int64 `xorm:"UNIQUE(federation_mapping) NOT NULL"`
|
||||
RawData map[string]any `xorm:"TEXT JSON"`
|
||||
ID int64 `xorm:"pk NOT NULL"`
|
||||
UserID int64 `xorm:"NOT NULL"`
|
||||
ExternalID string `xorm:"TEXT UNIQUE(federation_mapping) NOT NULL"`
|
||||
FederationHostID int64 `xorm:"UNIQUE(federation_mapping) NOT NULL"`
|
||||
}
|
||||
|
||||
func NewFederatedUser(userID int64, externalID string, federationHostID int64, rawData map[string]any) (FederatedUser, error) {
|
||||
func NewFederatedUser(userID int64, externalID string, federationHostID int64) (FederatedUser, error) {
|
||||
result := FederatedUser{
|
||||
UserID: userID,
|
||||
ExternalID: externalID,
|
||||
FederationHostID: federationHostID,
|
||||
RawData: rawData,
|
||||
}
|
||||
if valid, err := validation.IsValid(result); !valid {
|
||||
return FederatedUser{}, err
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue