(username, password string)
| 111 | } |
| 112 | |
| 113 | func (a *Auth) AuthPlain(username, password string) error { |
| 114 | if a.useHelper { |
| 115 | return external.AuthUsingHelper(a.helperPath, username, password) |
| 116 | } |
| 117 | |
| 118 | ent, err := Lookup(username) |
| 119 | if err != nil { |
| 120 | return err |
| 121 | } |
| 122 | |
| 123 | if !ent.IsAccountValid() { |
| 124 | return fmt.Errorf("shadow: account is expired") |
| 125 | } |
| 126 | |
| 127 | if !ent.IsPasswordValid() { |
| 128 | return fmt.Errorf("shadow: password is expired") |
| 129 | } |
| 130 | |
| 131 | if err := ent.VerifyPassword(password); err != nil { |
| 132 | if errors.Is(err, ErrWrongPassword) { |
| 133 | return module.ErrUnknownCredentials |
| 134 | } |
| 135 | return err |
| 136 | } |
| 137 | |
| 138 | return nil |
| 139 | } |
| 140 | |
| 141 | func init() { |
| 142 | modules.Register("auth.shadow", New) |
nothing calls this directly
no test coverage detected