Compare commits

..

No commits in common. "05749b493a2ed8f181b9fa40cac68d195c623be5" and "b54f3f32b5f4aeabb65933b5bc84142cea674721" have entirely different histories.

5 changed files with 58 additions and 9 deletions

View File

@ -298,6 +298,8 @@ func (h *Handlers) VerifyPin(ctx context.Context, sym string, input []byte) (res
if !ok {
return res, fmt.Errorf("missing session")
}
//AccountPin, _ := utils.ReadEntry(ctx, h.userdataStore, sessionId, utils.DATA_ACCOUNT_PIN)
store := h.userdataStore
AccountPin, err := store.ReadEntry(ctx, sessionId, utils.DATA_ACCOUNT_PIN)
if err != nil {
@ -334,12 +336,6 @@ func (h *Handlers) SaveFirstname(ctx context.Context, sym string, input []byte)
return res, fmt.Errorf("missing session")
}
flag_allow_update, _ := h.flagManager.GetFlag("flag_allow_update")
flag_single_edit, _ := h.flagManager.GetFlag("flag_single_edit")
res.FlagReset = append(res.FlagReset, flag_allow_update)
res.FlagSet = append(res.FlagSet, flag_single_edit)
if len(input) > 0 {
firstName := string(input)
store := h.userdataStore
@ -382,6 +378,15 @@ func (h *Handlers) SaveYob(ctx context.Context, sym string, input []byte) (resou
if !ok {
return res, fmt.Errorf("missing session")
}
flag_allow_update, _ := h.flagManager.GetFlag("flag_allow_update")
flag_single_edit, _ := h.flagManager.GetFlag("flag_single_edit")
execPath := utils.GetSingleEditExecutionPath("save_yob")
isSingleEdit := utils.MatchNavigationPath(execPath, h.st.ExecPath)
if isSingleEdit {
res.FlagReset = append(res.FlagReset, flag_allow_update)
res.FlagSet = append(res.FlagSet, flag_single_edit)
}
if len(input) == 4 {
yob := string(input)
store := h.userdataStore
@ -402,6 +407,17 @@ func (h *Handlers) SaveLocation(ctx context.Context, sym string, input []byte) (
if !ok {
return res, fmt.Errorf("missing session")
}
flag_allow_update, _ := h.flagManager.GetFlag("flag_allow_update")
flag_single_edit, _ := h.flagManager.GetFlag("flag_single_edit")
execPath := utils.GetSingleEditExecutionPath("save_location")
isSingleEdit := utils.MatchNavigationPath(execPath, h.st.ExecPath)
if isSingleEdit {
res.FlagReset = append(res.FlagReset, flag_allow_update)
res.FlagSet = append(res.FlagSet, flag_single_edit)
}
if len(input) > 0 {
location := string(input)
store := h.userdataStore
@ -422,6 +438,15 @@ func (h *Handlers) SaveGender(ctx context.Context, sym string, input []byte) (re
if !ok {
return res, fmt.Errorf("missing session")
}
flag_allow_update, _ := h.flagManager.GetFlag("flag_allow_update")
flag_single_edit, _ := h.flagManager.GetFlag("flag_single_edit")
execPath := utils.GetSingleEditExecutionPath("select_gender")
isSingleEdit := utils.MatchNavigationPath(execPath, h.st.ExecPath)
if isSingleEdit {
res.FlagReset = append(res.FlagReset, flag_allow_update)
res.FlagSet = append(res.FlagSet, flag_single_edit)
}
code := codeFromCtx(ctx)
if len(input) > 0 {
gender := string(input)

View File

@ -0,0 +1,24 @@
package utils
func MatchNavigationPath(a, b []string) bool {
if len(a) != len(b) {
return false
}
//Check if the navigation path matches with single edit
for i := range a {
if a[i] != b[i] {
return false
}
}
return true
}
func GetSingleEditExecutionPath(key string) []string {
paths := make(map[string][]string)
paths["select_gender"] = []string{"root", "main", "my_account", "edit_profile", "select_gender"}
paths["save_location"] = []string{"root", "main", "my_account", "edit_profile", "enter_location"}
paths["save_yob"] = []string{"root", "main", "my_account", "edit_profile", "enter_yob"}
return paths[key]
}

View File

@ -5,5 +5,5 @@ MOUT back 0
HALT
INCMP _ 0
LOAD save_location 0
CATCH pin_entry flag_single_edit 0
CATCH pin_entry flag_single_edit 1
INCMP enter_offerings *

View File

@ -5,5 +5,5 @@ HALT
INCMP _ 0
LOAD verify_yob 8
LOAD save_yob 0
CATCH pin_entry flag_single_edit 0
CATCH pin_entry flag_single_edit 1
INCMP enter_location *

View File

@ -6,7 +6,7 @@ MOUT unspecified 3
MOUT back 0
HALT
LOAD save_gender 0
CATCH pin_entry flag_single_edit 0
CATCH pin_entry flag_single_edit 1
INCMP _ 0
INCMP enter_yob 1
INCMP enter_yob 2