main 6af0a61

credentials.go RawHistoryFolder

1package user
2
3import "errors"
4
5// Credentials is an immutable value object for user credentials
6type Credentials struct {
7	userPassword string
8	rootPassword string
9}
10
11// NewCredentials creates new credentials with validation
12// rootPassword can be empty (root account will be locked, user uses sudo)
13func NewCredentials(userPassword, rootPassword string) (*Credentials, error) {
14	// Validate user password (required)
15	if err := ValidatePassword(userPassword); err != nil {
16		return nil, err
17	}
18
19	// Root password is optional - empty means root account locked
20	if rootPassword != "" {
21		if err := ValidatePassword(rootPassword); err != nil {
22			return nil, err
23		}
24		// Business rule: if root password set, it must differ from user password
25		if userPassword == rootPassword {
26			return nil, errors.New("user and root passwords must differ")
27		}
28	}
29
30	return &Credentials{
31		userPassword: userPassword,
32		rootPassword: rootPassword,
33	}, nil
34}
35
36// HasPassword returns true if password is set
37func (c *Credentials) HasPassword() bool {
38	return c.userPassword != "" && c.rootPassword != ""
39}
40
41// String returns a redacted representation
42func (c *Credentials) String() string {
43	return "Credentials(set=true)"
44}
45
46// ValidatePassword validates password strength
47func ValidatePassword(password string) error {
48	if password == "" {
49		return errors.New("password cannot be empty")
50	}
51
52	// Minimum 4 characters
53	if len(password) < 4 {
54		return errors.New("password must be at least 4 characters")
55	}
56
57	// Maximum 128 characters (reasonable limit)
58	if len(password) > 128 {
59		return errors.New("password cannot exceed 128 characters")
60	}
61
62	return nil
63}

Keyboard shortcuts

Single-key shortcuts are on. ctrl k and esc work whatever this says.

ctrl k :
go to a section, branch, tag, file or repository
?
this list
j k
move the row cursor down / up
enter
open the row under the cursor; on Files, a directory opens or closes in place
↑ ↓ ← → home end
in the file tree (focus on a row): previous / next row, close / open a directory or go to its parent / first entry, first / last row. They never open a file
l h
on Files: open a directory or a file / close a directory or go up to its parent, then to the parent page. Elsewhere: into the side panel (on a merge request, its files) / back to the content; there j k move between its controls
g g G
first / last row
/
filter the list; on Files, find a file anywhere in the repository (esc clears, enter opens the best match)
b
switch branch or tag
g s g f g c g b g m g i g r g a
tabs: summary, files, commits, branches & tags, merge requests, issues, releases, actions (when available)
g h
home
w
wide mode: use the whole width of the screen, or not (remembered)
y
copy a permalink pinned to the commit
d u x
diff: split / unified / collapse or expand all
e E
diff: the whole file in view / every file, with the lines the hunks hide
n
merge request: next note in the diff
esc
close a dialog, leave a field

Branches 1

Tags 0

    ↑↓ moveenter openesc close