2021-03-16 01:05:24 +03:00
/ *
GoToSocial
Copyright ( C ) 2021 GoToSocial Authors admin @ gotosocial . org
This program is free software : you can redistribute it and / or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation , either version 3 of the License , or
( at your option ) any later version .
This program is distributed in the hope that it will be useful ,
but WITHOUT ANY WARRANTY ; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
GNU Affero General Public License for more details .
You should have received a copy of the GNU Affero General Public License
along with this program . If not , see < http : //www.gnu.org/licenses/>.
* /
2021-04-19 20:42:19 +03:00
package gtsmodel
2021-03-16 01:05:24 +03:00
import (
"net"
"time"
)
2021-03-20 21:04:27 +03:00
// User represents an actual human user of gotosocial. Note, this is a LOCAL gotosocial user, not a remote account.
// To cross reference this local user with their account (which can be local or remote), use the AccountID field.
2021-03-16 01:05:24 +03:00
type User struct {
2021-03-20 21:04:27 +03:00
/ *
BASIC INFO
* /
// id of this user in the local database; the end-user will never need to know this, it's strictly internal
2021-08-25 16:34:33 +03:00
ID string ` bun:"type:CHAR(26),pk,notnull,unique" `
2021-03-20 21:04:27 +03:00
// confirmed email address for this user, this should be unique -- only one email address registered per instance, multiple users per email are not supported
2021-08-25 16:34:33 +03:00
Email string ` bun:"default:null,unique,nullzero" `
2021-03-20 21:04:27 +03:00
// The id of the local gtsmodel.Account entry for this user, if it exists (unconfirmed users don't have an account yet)
2021-08-25 16:34:33 +03:00
AccountID string ` bun:"type:CHAR(26),unique,nullzero" `
Account * Account ` bun:"rel:belongs-to" `
2021-03-20 21:04:27 +03:00
// The encrypted password of this user, generated using https://pkg.go.dev/golang.org/x/crypto/bcrypt#GenerateFromPassword. A salt is included so we're safe against 🌈 tables
2021-08-25 16:34:33 +03:00
EncryptedPassword string ` bun:",notnull" `
2021-03-20 21:04:27 +03:00
/ *
USER METADATA
* /
// When was this user created?
2021-08-25 16:34:33 +03:00
CreatedAt time . Time ` bun:",nullzero,notnull,default:current_timestamp" `
2021-03-20 21:04:27 +03:00
// From what IP was this user created?
2021-08-25 16:34:33 +03:00
SignUpIP net . IP ` bun:",nullzero" `
2021-03-20 21:04:27 +03:00
// When was this user updated (eg., password changed, email address changed)?
2021-08-25 16:34:33 +03:00
UpdatedAt time . Time ` bun:",nullzero,notnull,default:current_timestamp" `
2021-03-20 21:04:27 +03:00
// When did this user sign in for their current session?
2021-08-25 16:34:33 +03:00
CurrentSignInAt time . Time ` bun:",nullzero" `
2021-03-20 21:04:27 +03:00
// What's the most recent IP of this user
2021-08-25 16:34:33 +03:00
CurrentSignInIP net . IP ` bun:",nullzero" `
2021-03-20 21:04:27 +03:00
// When did this user last sign in?
2021-08-25 16:34:33 +03:00
LastSignInAt time . Time ` bun:",nullzero" `
2021-03-20 21:04:27 +03:00
// What's the previous IP of this user?
2021-08-25 16:34:33 +03:00
LastSignInIP net . IP ` bun:",nullzero" `
2021-03-20 21:04:27 +03:00
// How many times has this user signed in?
SignInCount int
// id of the user who invited this user (who let this guy in?)
2021-08-25 16:34:33 +03:00
InviteID string ` bun:"type:CHAR(26),nullzero" `
2021-03-20 21:04:27 +03:00
// What languages does this user want to see?
ChosenLanguages [ ] string
// What languages does this user not want to see?
FilteredLanguages [ ] string
// In what timezone/locale is this user located?
Locale string
// Which application id created this user? See gtsmodel.Application
2021-08-25 16:34:33 +03:00
CreatedByApplicationID string ` bun:"type:CHAR(26),nullzero" `
CreatedByApplication * Application ` bun:"rel:belongs-to" `
2021-03-20 21:04:27 +03:00
// When did we last contact this user
2021-08-25 16:34:33 +03:00
LastEmailedAt time . Time ` bun:",nullzero" `
2021-03-20 21:04:27 +03:00
/ *
USER CONFIRMATION
* /
// What confirmation token did we send this user/what are we expecting back?
ConfirmationToken string
// When did the user confirm their email address
2021-08-25 16:34:33 +03:00
ConfirmedAt time . Time ` bun:",nullzero" `
2021-03-20 21:04:27 +03:00
// When did we send email confirmation to this user?
2021-08-25 16:34:33 +03:00
ConfirmationSentAt time . Time ` bun:",nullzero" `
2021-03-20 21:04:27 +03:00
// Email address that hasn't yet been confirmed
UnconfirmedEmail string
/ *
ACL FLAGS
* /
// Is this user a moderator?
Moderator bool
// Is this user an admin?
Admin bool
// Is this user disabled from posting?
Disabled bool
// Has this user been approved by a moderator?
Approved bool
/ *
USER SECURITY
* /
// The generated token that the user can use to reset their password
ResetPasswordToken string
// When did we email the user their reset-password email?
2021-08-25 16:34:33 +03:00
ResetPasswordSentAt time . Time ` bun:",nullzero" `
2021-03-20 21:04:27 +03:00
2021-03-16 01:05:24 +03:00
EncryptedOTPSecret string
EncryptedOTPSecretIv string
EncryptedOTPSecretSalt string
OTPRequiredForLogin bool
OTPBackupCodes [ ] string
2021-03-20 21:08:17 +03:00
ConsumedTimestamp int
RememberToken string
SignInToken string
2021-08-25 16:34:33 +03:00
SignInTokenSentAt time . Time ` bun:",nullzero" `
2021-03-20 21:08:17 +03:00
WebauthnID string
2021-03-16 01:05:24 +03:00
}