Skip to content
This repository has been archived by the owner on Sep 9, 2022. It is now read-only.

Commit

Permalink
fix: fix secman config file issue in secman auth login command
Browse files Browse the repository at this point in the history
  • Loading branch information
abdfnx committed Mar 18, 2022
1 parent dbeb27a commit 7237221
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions pkg/auth/login/login.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,11 @@ import (
"github.com/scmn-dev/secman/internal/shared"
)

const (
textInput shared.Index = iota
verfiyButton
cancelButton
)
type InitMsg struct{}

type model struct {
styles shared.Styles
focusIndex int
index shared.Index
inputs []textinput.Model
spinner spinner.Model
state shared.State
Expand Down Expand Up @@ -144,6 +139,12 @@ func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {

return m, nil

case InitMsg:
m.state = shared.Ready
m.message = m.styles.Error.Render("~/.secman/secman.json not found, run ") + m.styles.Subtle.Render("`secman init`")

return m, nil

case shared.ErrorMsg:
m.state = shared.Ready
m.message = m.styles.Error.Render("Invalid email or master password. if you don't have an account, please create one using the command ") + m.styles.Subtle.Render("`secman auth create`")
Expand Down Expand Up @@ -220,6 +221,8 @@ func sma(m model) tea.Cmd {
return shared.OtherMsg{}
} else if strings.Contains(out, "200") {
return shared.SuccessMsg{}
} else if strings.Contains(out, "init") {
return InitMsg{}
}

return shared.SetMsg(out)
Expand Down

0 comments on commit 7237221

Please sign in to comment.