MCPcopy
hub / github.com/filebrowser/filebrowser / createUser

Method createUser

auth/proxy.go:30–66  ·  view source on GitHub ↗
(usr users.Store, setting *settings.Settings, srv *settings.Server, username string)

Source from the content-addressed store, hash-verified

28}
29
30func (a ProxyAuth) createUser(usr users.Store, setting *settings.Settings, srv *settings.Server, username string) (*users.User, error) {
31 const randomPasswordLength = settings.DefaultMinimumPasswordLength + 10
32 pwd, err := users.RandomPwd(randomPasswordLength)
33 if err != nil {
34 return nil, err
35 }
36
37 var hashedRandomPassword string
38 hashedRandomPassword, err = users.ValidateAndHashPwd(pwd, setting.MinimumPasswordLength)
39 if err != nil {
40 return nil, err
41 }
42
43 user := &users.User{
44 Username: username,
45 Password: hashedRandomPassword,
46 LockPassword: true,
47 }
48 setting.Defaults.Apply(user)
49 user.Perm.Admin = false
50 user.Perm.Execute = false
51 user.Commands = []string{}
52
53 var userHome string
54 userHome, err = setting.MakeUserDir(user.Username, user.Scope, srv.Root)
55 if err != nil {
56 return nil, err
57 }
58 user.Scope = userHome
59
60 err = usr.Save(user)
61 if err != nil {
62 return nil, err
63 }
64
65 return user, nil
66}
67
68// LoginPage tells that proxy auth doesn't require a login page.
69func (a ProxyAuth) LoginPage() bool {

Callers 1

AuthMethod · 0.95

Calls 5

RandomPwdFunction · 0.92
ValidateAndHashPwdFunction · 0.92
ApplyMethod · 0.80
MakeUserDirMethod · 0.80
SaveMethod · 0.65

Tested by

no test coverage detected