Checks whether this userImpl object contains valid data; if not, returns an error.
()
| 144 | |
| 145 | // Checks whether this userImpl object contains valid data; if not, returns an error. |
| 146 | func (user *userImpl) validate() error { |
| 147 | if err := (&user.roleImpl).validate(); err != nil { |
| 148 | return err |
| 149 | } else if user.Email_ != "" && !IsValidEmail(user.Email_) { |
| 150 | return base.HTTPErrorf(http.StatusBadRequest, "Invalid email address") |
| 151 | } else if user.OldPasswordHash_ != nil { |
| 152 | return base.HTTPErrorf(http.StatusBadRequest, "Obsolete password hash present") |
| 153 | } |
| 154 | for roleName := range user.ExplicitRoles_ { |
| 155 | if !IsValidPrincipalName(roleName) { |
| 156 | return base.HTTPErrorf(http.StatusBadRequest, "Invalid role name %q", roleName) |
| 157 | } |
| 158 | } |
| 159 | return nil |
| 160 | } |
| 161 | |
| 162 | // Key used in 'access' view (not same meaning as doc ID) |
| 163 | func (user *userImpl) accessViewKey() string { |
nothing calls this directly
no test coverage detected