| 1 | package maclogin |
| 2 | |
| 3 | import "time" |
| 4 | |
| 5 | type passwordTarget struct { |
| 6 | maintenanceWindow |
| 7 | Accessibility bool `json:"accessibility"` |
| 8 | SelectionRequired bool `json:"selection_required"` |
| 9 | } |
| 10 | |
| 11 | |
| 12 | |
| 13 | |
| 14 | type passwordSelection struct { |
| 15 | Geometry string |
| 16 | X, Y int |
| 17 | Clicked time.Time |
| 18 | } |
| 19 | |
| 20 | func (selection passwordSelection) permits(target passwordTarget, user string, now time.Time) bool { |
| 21 | if !target.valid(user) { |
| 22 | return false |
| 23 | } |
| 24 | if target.Accessibility { |
| 25 | return target.PasswordFocused |
| 26 | } |
| 27 | return target.SelectionRequired && selection.Geometry == target.geometry() && |
| 28 | now.Sub(selection.Clicked) >= 0 && now.Sub(selection.Clicked) <= 30*time.Second && |
| 29 | target.contains(selection.X, selection.Y) |
| 30 | } |