fix: registration fills only an explicit allow-list and never takes the IP columns from the body
User.RegisterFillable lists what a registration body may set: name, surname, email, password, preferred_locale and marketing_consent. RegisterUser fills from it instead of Fillable, so organisation_id, organisation_role, is_onboarded and must_change_password can no longer be mass-assigned through POST /register, and created_ip_address and last_ip_address come only from RegisterOptions.IP. Fillable is unchanged for the admin form and trusted application code.
This commit is contained in:
@@ -81,8 +81,12 @@ func (User) AttachRelations() []attach.Relation {
|
||||
return []attach.Relation{{Name: AvatarField, Public: true}}
|
||||
}
|
||||
|
||||
// Fillable is the register/update field list. Username, PIN, and GDPR columns
|
||||
// stay out of Phase 7 because no ported handler reads them.
|
||||
// Fillable is the mass-assignment backstop of the admin Users form and of
|
||||
// trusted application code: cabana intersects it with the form's writable
|
||||
// fields (and an application's form extensions) and keeps organisation_id
|
||||
// protected. Registration does not use it: RegisterUser fills only
|
||||
// RegisterFillable. Username, PIN and GDPR columns stay out because no
|
||||
// ported handler reads them.
|
||||
func (User) Fillable() []string {
|
||||
return []string{
|
||||
"name", "surname", "email", "password", "created_ip_address", "last_ip_address",
|
||||
@@ -91,6 +95,20 @@ func (User) Fillable() []string {
|
||||
}
|
||||
}
|
||||
|
||||
// RegisterFillable is the explicit allow-list of the columns a registration
|
||||
// body may set (POST /register and controllers.RegisterUser): name, surname,
|
||||
// email, password (stored as its hash), preferred_locale and
|
||||
// marketing_consent. A registration body can never set organisation_id or
|
||||
// organisation_role (membership is the administrator's or the
|
||||
// application's), created_ip_address or last_ip_address (server-set from
|
||||
// RegisterOptions.IP only), is_onboarded (application-owned onboarding
|
||||
// state) or must_change_password (set by an administrator or the
|
||||
// require-password-change command). The activation, reset, address proof,
|
||||
// handle and permission columns are never fillable at all.
|
||||
func (User) RegisterFillable() []string {
|
||||
return []string{"name", "surname", "email", "password", "preferred_locale", "marketing_consent"}
|
||||
}
|
||||
|
||||
// Hidden mirrors PHP User::$hidden for the secrets this model stores.
|
||||
func (User) Hidden() []string {
|
||||
return []string{"password", "reset_password_code", "activation_code"}
|
||||
|
||||
Reference in New Issue
Block a user