ef25d18d9c
(cherry picked from commit 2a25be788bdf3b58b236cb2a9f503b569703a0c6) (cherry picked from commit b270d5815c80f387759eecbfcb588e548f5ed956) (cherry picked from commit e7382cc71e43c52abcabc59d09128450ce415d26) (cherry picked from commit 665400ea1e92405f41590bccf800714440ded50a) (cherry picked from commit f5b2c691f17d6a66fd8041a83b36194f7d630339) (cherry picked from commit 3df97adfefac63ddd1d44cc553a2c81087706d47) (cherry picked from commit 494f6eafc15f235cd7ca5d4f01e7ac16eea8bd5b) (cherry picked from commit 822e3d2c833e2a92d337812a93a6c78638b14456) (cherry picked from commit 7460f1256852256048e7a7eb1dad108a0caa3567) (cherry picked from commit f6cd70881e828688a73f277252cdf1bf1904fbe2) (cherry picked from commit c669ce8173f0f819834436fd571d25c8678ec187) (cherry picked from commit 1d5a433e0282681c6ebcd9ee0cb5deb644509f7d) (cherry picked from commit c1a4dc150c617a8210c5907e9d93e41f01a01a2f) (cherry picked from commit dd1c971c6c86ae80323c47084eb724d305428943) (cherry picked from commit 8d2dcd9b1ed055875bdc123aab6bf6ea54539296) (cherry picked from commit b6bb8fd2750c76454cbc014134d3a6049021ca5a) (cherry picked from commit d4b71fe96e043389453a6595ccae0faae0113ca3) (cherry picked from commit e204ec0b2359b85bde65d2b56463dd8e3655405f) (cherry picked from commit 8d9f1174bd568fa8c74e433981b3bf79ba91bfbf) (cherry picked from commit e314a7d5ba2aea572bffe8c69e36cc60ef7663f5) (cherry picked from commit 48b3ad5a303900474ad87014d90889c9fd4a9b9c) (cherry picked from commit 71ed4b7c694ab6ac7e2647274b202f49c9502e0f) (cherry picked from commit d63324ccb647a93c026a5a01ccd79cd73ec8b600) (cherry picked from commit 9249e893dbb096418945a462d35327013f865bbc) (cherry picked from commit 78f156427b6ff2dd6e7dc4092f7ea4e18786cdb0) (cherry picked from commit c3d4a1a602712ff64f152a0c78d2ac438b957dd4) (cherry picked from commit 83b1855f559e315143cdd82bc9f028c1302cf9b2) (cherry picked from commit 319815d9b1634dfe99b00fb8334d4342280b5d57) (cherry picked from commit c4fcbfd2972b533e85e934ba5f23478c52b86dea) (cherry picked from commit fb58c852229b8944725d1fe48496cf2e7878af34) (cherry picked from commit 69c24e3e8b2775e0ff8d4dc95573ad922f8f0be8) (cherry picked from commit 1e9ec4737a2a514253038ccda5b05436c216ab7b) (cherry picked from commit 70439970c1f1b0d19e8084fe819665a780a9f6e7) (cherry picked from commit 7e6146c1a85108fd2226e3d403cfd81617fdf3f1) (cherry picked from commit 7adf6d586919e876dbf1729b82065664730a9657) (cherry picked from commit 8985e1734365d2a887c3842b1b5e051b41620bad) (cherry picked from commit fd4dc3ebcaa05243070bfa4f938d534c11ef5471) (cherry picked from commit d31bf1639e9c2e7c2e59b17c00f0797177aa3ce4) (cherry picked from commit d2a9b6dea0f9b0587141a85ca2c757f3d747cb1d) (cherry picked from commit 0d9279bc857edc1ef47e106d4ba3fce1eec7589e) (cherry picked from commit 0591a15cee319048097a8f61d9a7b64086303007) (cherry picked from commit 3ad88f11467c59b5f70631ac75d2e89974c3f83f) (cherry picked from commit 5501f5b2e54f555415a764580141e565ca0434e0) (cherry picked from commit 9b9f62f7744c924769a5ca0d300abe6470f411c4) (cherry picked from commit dd2e5f525d4a5461c7292bb4c7611dc79b85dc5e) (cherry picked from commit 9b489fd8a559bae26b1e4636b134499cee80d558) (cherry picked from commit 60c820562a9133d69a52ff911f5c67a18c8c6b75) (cherry picked from commit 084d73231711affbd09559db64963e4932712a7b) (cherry picked from commit e1bb077d6e76797c3a604f298843b3cdbfb57dcb)
70 lines
1.6 KiB
Go
70 lines
1.6 KiB
Go
// Copyright 2022 The Gitea Authors. All rights reserved.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package user
|
|
|
|
import (
|
|
"strings"
|
|
|
|
"code.gitea.io/gitea/modules/structs"
|
|
)
|
|
|
|
const (
|
|
GhostUserID = -1
|
|
GhostUserName = "Ghost"
|
|
GhostUserLowerName = "ghost"
|
|
)
|
|
|
|
// NewGhostUser creates and returns a fake user for someone has deleted their account.
|
|
func NewGhostUser() *User {
|
|
return &User{
|
|
ID: GhostUserID,
|
|
Name: GhostUserName,
|
|
LowerName: GhostUserLowerName,
|
|
}
|
|
}
|
|
|
|
// IsGhost check if user is fake user for a deleted account
|
|
func (u *User) IsGhost() bool {
|
|
if u == nil {
|
|
return false
|
|
}
|
|
return u.ID == GhostUserID && u.Name == GhostUserName
|
|
}
|
|
|
|
// NewReplaceUser creates and returns a fake user for external user
|
|
func NewReplaceUser(name string) *User {
|
|
return &User{
|
|
ID: 0,
|
|
Name: name,
|
|
LowerName: strings.ToLower(name),
|
|
}
|
|
}
|
|
|
|
const (
|
|
ActionsUserID = -2
|
|
ActionsUserName = "forgejo-actions"
|
|
ActionsFullName = "Forgejo Actions"
|
|
ActionsEmail = "noreply@forgejo.org"
|
|
)
|
|
|
|
// NewActionsUser creates and returns a fake user for running the actions.
|
|
func NewActionsUser() *User {
|
|
return &User{
|
|
ID: ActionsUserID,
|
|
Name: ActionsUserName,
|
|
LowerName: ActionsUserName,
|
|
IsActive: true,
|
|
FullName: ActionsFullName,
|
|
Email: ActionsEmail,
|
|
KeepEmailPrivate: true,
|
|
LoginName: ActionsUserName,
|
|
Type: UserTypeIndividual,
|
|
AllowCreateOrganization: true,
|
|
Visibility: structs.VisibleTypePublic,
|
|
}
|
|
}
|
|
|
|
func (u *User) IsActions() bool {
|
|
return u != nil && u.ID == ActionsUserID
|
|
}
|