Skip to content

Commit

Permalink
Guard against unknown layout type
Browse files Browse the repository at this point in the history
This avoids any potential segfaults when trying to draw the view.

Co-authored-by: Jean-Baptiste Lallement <[email protected]>
  • Loading branch information
didrocks and jibel committed Aug 9, 2023
1 parent c3a8b0d commit 8b2523c
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions pam/authorization.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,12 +170,17 @@ func (m *authorizationModel) Compose(sessionID string, layout *authd.UILayout) t
form.setEntryValue(oldEntryValue)
}
m.currentModel = form
default:
return sendEvent(pamSystemError{msg: fmt.Sprintf("unknown layout type: %q", layout.Type)})
}

return sendEvent(startAuthorization{})
}

func (m authorizationModel) View() string {
if m.currentModel == nil {
return ""
}
return lipgloss.JoinVertical(lipgloss.Left,
m.currentModel.View(),
m.errorMsg,
Expand Down

0 comments on commit 8b2523c

Please sign in to comment.