Compare commits
No commits in common. "8f7d5ff66d760fa531ae61b6b84cd10a6d16e790" and "e2d5546de1dae1e0e2c52b5a7a682dee2d53cc27" have entirely different histories.
8f7d5ff66d
...
e2d5546de1
@ -1,7 +1,6 @@
|
|||||||
package application
|
package application
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"path"
|
"path"
|
||||||
@ -454,14 +453,6 @@ func (h *MenuHandlers) CheckBlockedNumPinMisMatch(ctx context.Context, sym strin
|
|||||||
return res, nil
|
return res, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// ResetInvalidPIN resets the invalid PIN flag
|
|
||||||
func (h *MenuHandlers) ResetInvalidPIN(ctx context.Context, sym string, input []byte) (resource.Result, error) {
|
|
||||||
var res resource.Result
|
|
||||||
flag_invalid_pin, _ := h.flagManager.GetFlag("flag_invalid_pin")
|
|
||||||
res.FlagReset = append(res.FlagReset, flag_invalid_pin)
|
|
||||||
return res, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// ConfirmPinChange validates user's new PIN. If input matches the temporary PIN, saves it as the new account PIN.
|
// ConfirmPinChange validates user's new PIN. If input matches the temporary PIN, saves it as the new account PIN.
|
||||||
func (h *MenuHandlers) ConfirmPinChange(ctx context.Context, sym string, input []byte) (resource.Result, error) {
|
func (h *MenuHandlers) ConfirmPinChange(ctx context.Context, sym string, input []byte) (resource.Result, error) {
|
||||||
var res resource.Result
|
var res resource.Result
|
||||||
@ -716,6 +707,10 @@ func (h *MenuHandlers) SaveFirstname(ctx context.Context, sym string, input []by
|
|||||||
logg.ErrorCtxf(ctx, "failed to write firstName entry with", "key", storedb.DATA_FIRST_NAME, "value", temporaryFirstName, "error", err)
|
logg.ErrorCtxf(ctx, "failed to write firstName entry with", "key", storedb.DATA_FIRST_NAME, "value", temporaryFirstName, "error", err)
|
||||||
return res, err
|
return res, err
|
||||||
}
|
}
|
||||||
|
err := h.constructAccountAlias(ctx)
|
||||||
|
if err != nil {
|
||||||
|
return res, err
|
||||||
|
}
|
||||||
res.FlagSet = append(res.FlagSet, flag_firstname_set)
|
res.FlagSet = append(res.FlagSet, flag_firstname_set)
|
||||||
} else {
|
} else {
|
||||||
if firstNameSet {
|
if firstNameSet {
|
||||||
@ -1109,18 +1104,6 @@ func (h *MenuHandlers) GetCurrentProfileInfo(ctx context.Context, sym string, in
|
|||||||
}
|
}
|
||||||
res.FlagSet = append(res.FlagSet, flag_offerings_set)
|
res.FlagSet = append(res.FlagSet, flag_offerings_set)
|
||||||
res.Content = string(profileInfo)
|
res.Content = string(profileInfo)
|
||||||
case storedb.DATA_ACCOUNT_ALIAS:
|
|
||||||
profileInfo, err = store.ReadEntry(ctx, sessionId, storedb.DATA_ACCOUNT_ALIAS)
|
|
||||||
if err != nil {
|
|
||||||
if db.IsNotFound(err) {
|
|
||||||
res.Content = defaultValue
|
|
||||||
break
|
|
||||||
}
|
|
||||||
logg.ErrorCtxf(ctx, "Failed to read account alias entry with", "key", "error", storedb.DATA_ACCOUNT_ALIAS, err)
|
|
||||||
return res, err
|
|
||||||
}
|
|
||||||
res.FlagSet = append(res.FlagSet, flag_offerings_set)
|
|
||||||
res.Content = string(profileInfo)
|
|
||||||
default:
|
default:
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
@ -1246,19 +1229,13 @@ func (h *MenuHandlers) UpdateAllProfileItems(ctx context.Context, sym string, in
|
|||||||
if !ok {
|
if !ok {
|
||||||
return res, fmt.Errorf("missing session")
|
return res, fmt.Errorf("missing session")
|
||||||
}
|
}
|
||||||
flag_alias_set, _ := h.flagManager.GetFlag("flag_alias_set")
|
|
||||||
aliasSet := h.st.MatchFlag(flag_alias_set, true)
|
|
||||||
|
|
||||||
err := h.insertProfileItems(ctx, sessionId, &res)
|
err := h.insertProfileItems(ctx, sessionId, &res)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return res, err
|
return res, err
|
||||||
}
|
}
|
||||||
//Only request an alias if it has not been set yet:
|
err = h.constructAccountAlias(ctx)
|
||||||
if !aliasSet {
|
if err != nil {
|
||||||
err = h.constructAccountAlias(ctx)
|
return res, err
|
||||||
if err != nil {
|
|
||||||
return res, err
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return res, nil
|
return res, nil
|
||||||
}
|
}
|
||||||
@ -1298,7 +1275,6 @@ func (h *MenuHandlers) Authorize(ctx context.Context, sym string, input []byte)
|
|||||||
flag_incorrect_pin, _ := h.flagManager.GetFlag("flag_incorrect_pin")
|
flag_incorrect_pin, _ := h.flagManager.GetFlag("flag_incorrect_pin")
|
||||||
flag_account_authorized, _ := h.flagManager.GetFlag("flag_account_authorized")
|
flag_account_authorized, _ := h.flagManager.GetFlag("flag_account_authorized")
|
||||||
flag_allow_update, _ := h.flagManager.GetFlag("flag_allow_update")
|
flag_allow_update, _ := h.flagManager.GetFlag("flag_allow_update")
|
||||||
flag_invalid_pin, _ := h.flagManager.GetFlag("flag_invalid_pin")
|
|
||||||
|
|
||||||
store := h.userdataStore
|
store := h.userdataStore
|
||||||
AccountPin, err := store.ReadEntry(ctx, sessionId, storedb.DATA_ACCOUNT_PIN)
|
AccountPin, err := store.ReadEntry(ctx, sessionId, storedb.DATA_ACCOUNT_PIN)
|
||||||
@ -1335,9 +1311,6 @@ func (h *MenuHandlers) Authorize(ctx context.Context, sym string, input []byte)
|
|||||||
return res, nil
|
return res, nil
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if string(input) != "0" {
|
|
||||||
res.FlagSet = append(res.FlagSet, flag_invalid_pin)
|
|
||||||
}
|
|
||||||
return res, nil
|
return res, nil
|
||||||
}
|
}
|
||||||
return res, nil
|
return res, nil
|
||||||
@ -2420,91 +2393,6 @@ func (h *MenuHandlers) constructAccountAlias(ctx context.Context) error {
|
|||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
//RequestCustomAlias requests an ENS based alias name based on a user's input,then saves it as temporary value
|
|
||||||
func (h *MenuHandlers) RequestCustomAlias(ctx context.Context, sym string, input []byte) (resource.Result, error) {
|
|
||||||
var res resource.Result
|
|
||||||
sessionId, ok := ctx.Value("SessionId").(string)
|
|
||||||
if !ok {
|
|
||||||
return res, fmt.Errorf("missing session")
|
|
||||||
}
|
|
||||||
store := h.userdataStore
|
|
||||||
aliasHint, err := store.ReadEntry(ctx, sessionId, storedb.DATA_TEMPORARY_VALUE)
|
|
||||||
if err != nil {
|
|
||||||
if db.IsNotFound(err) {
|
|
||||||
return res, nil
|
|
||||||
}
|
|
||||||
return res, err
|
|
||||||
}
|
|
||||||
//Ensures that the call doesn't happen twice for the same alias hint
|
|
||||||
if !bytes.Equal(aliasHint, input) {
|
|
||||||
err = store.WriteEntry(ctx, sessionId, storedb.DATA_TEMPORARY_VALUE, []byte(string(input)))
|
|
||||||
if err != nil {
|
|
||||||
return res, err
|
|
||||||
}
|
|
||||||
pubKey, err := store.ReadEntry(ctx, sessionId, storedb.DATA_PUBLIC_KEY)
|
|
||||||
if err != nil {
|
|
||||||
if db.IsNotFound(err) {
|
|
||||||
return res, nil
|
|
||||||
}
|
|
||||||
}
|
|
||||||
aliasResult, err := h.accountService.RequestAlias(ctx, string(pubKey), string(input))
|
|
||||||
if err != nil {
|
|
||||||
logg.ErrorCtxf(ctx, "failed to retrieve alias", "alias", string(aliasHint), "error_alias_request", err)
|
|
||||||
return res, fmt.Errorf("Failed to retrieve alias: %s", err.Error())
|
|
||||||
}
|
|
||||||
alias := aliasResult.Alias
|
|
||||||
|
|
||||||
//Store the returned alias,wait for user to confirm it as new account alias
|
|
||||||
err = store.WriteEntry(ctx, sessionId, storedb.DATA_TEMPORARY_VALUE, []byte(alias))
|
|
||||||
if err != nil {
|
|
||||||
logg.ErrorCtxf(ctx, "failed to write account alias", "key", storedb.DATA_TEMPORARY_VALUE, "value", alias, "error", err)
|
|
||||||
return res, err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return res, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
//GetSuggestedAlias loads and displays the suggested alias name from the temporary value
|
|
||||||
func (h *MenuHandlers) GetSuggestedAlias(ctx context.Context, sym string, input []byte) (resource.Result, error) {
|
|
||||||
var res resource.Result
|
|
||||||
store := h.userdataStore
|
|
||||||
|
|
||||||
sessionId, ok := ctx.Value("SessionId").(string)
|
|
||||||
if !ok {
|
|
||||||
return res, fmt.Errorf("missing session")
|
|
||||||
}
|
|
||||||
suggestedAlias, err := store.ReadEntry(ctx, sessionId, storedb.DATA_TEMPORARY_VALUE)
|
|
||||||
if err != nil {
|
|
||||||
return res, nil
|
|
||||||
}
|
|
||||||
res.Content = string(suggestedAlias)
|
|
||||||
return res, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
//ConfirmNewAlias reads the suggested alias from the temporary value and confirms it as the new account alias.
|
|
||||||
func (h *MenuHandlers) ConfirmNewAlias(ctx context.Context, sym string, input []byte) (resource.Result, error) {
|
|
||||||
var res resource.Result
|
|
||||||
store := h.userdataStore
|
|
||||||
|
|
||||||
flag_alias_set, _ := h.flagManager.GetFlag("flag_alias_set")
|
|
||||||
|
|
||||||
sessionId, ok := ctx.Value("SessionId").(string)
|
|
||||||
if !ok {
|
|
||||||
return res, fmt.Errorf("missing session")
|
|
||||||
}
|
|
||||||
newAlias, err := store.ReadEntry(ctx, sessionId, storedb.DATA_TEMPORARY_VALUE)
|
|
||||||
if err != nil {
|
|
||||||
return res, nil
|
|
||||||
}
|
|
||||||
err = store.WriteEntry(ctx, sessionId, storedb.DATA_ACCOUNT_ALIAS, []byte(string(newAlias)))
|
|
||||||
if err != nil {
|
|
||||||
logg.ErrorCtxf(ctx, "failed to clear DATA_ACCOUNT_ALIAS_VALUE entry with", "key", storedb.DATA_ACCOUNT_ALIAS, "value", "empty", "error", err)
|
|
||||||
return res, err
|
|
||||||
}
|
|
||||||
|
|
||||||
res.FlagSet = append(res.FlagSet, flag_alias_set)
|
|
||||||
return res, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// ClearTemporaryValue empties the DATA_TEMPORARY_VALUE at the main menu to prevent
|
// ClearTemporaryValue empties the DATA_TEMPORARY_VALUE at the main menu to prevent
|
||||||
// previously stored data from being accessed
|
// previously stored data from being accessed
|
||||||
|
|||||||
@ -124,11 +124,6 @@ func (ls *LocalHandlerService) GetHandler(accountService remote.AccountService)
|
|||||||
ls.DbRs.AddLocalFunc("set_back", appHandlers.SetBack)
|
ls.DbRs.AddLocalFunc("set_back", appHandlers.SetBack)
|
||||||
ls.DbRs.AddLocalFunc("show_blocked_account", appHandlers.ShowBlockedAccount)
|
ls.DbRs.AddLocalFunc("show_blocked_account", appHandlers.ShowBlockedAccount)
|
||||||
ls.DbRs.AddLocalFunc("clear_temporary_value", appHandlers.ClearTemporaryValue)
|
ls.DbRs.AddLocalFunc("clear_temporary_value", appHandlers.ClearTemporaryValue)
|
||||||
ls.DbRs.AddLocalFunc("reset_invalid_pin", appHandlers.ResetInvalidPIN)
|
|
||||||
ls.DbRs.AddLocalFunc("request_custom_alias", appHandlers.RequestCustomAlias)
|
|
||||||
ls.DbRs.AddLocalFunc("get_suggested_alias", appHandlers.GetSuggestedAlias)
|
|
||||||
ls.DbRs.AddLocalFunc("confirm_new_alias", appHandlers.ConfirmNewAlias)
|
|
||||||
|
|
||||||
ls.first = appHandlers.Init
|
ls.first = appHandlers.Init
|
||||||
|
|
||||||
return appHandlers, nil
|
return appHandlers, nil
|
||||||
|
|||||||
@ -1,2 +0,0 @@
|
|||||||
Your full alias will be: {{.get_suggested_alias}}
|
|
||||||
Please enter your PIN to confirm:
|
|
||||||
@ -1,12 +0,0 @@
|
|||||||
LOAD reset_invalid_pin 6
|
|
||||||
RELOAD reset_invalid_pin
|
|
||||||
LOAD get_suggested_alias 0
|
|
||||||
RELOAD get_suggested_alias
|
|
||||||
MAP get_suggested_alias
|
|
||||||
MOUT back 0
|
|
||||||
HALT
|
|
||||||
INCMP _ 0
|
|
||||||
RELOAD authorize_account
|
|
||||||
CATCH incorrect_pin flag_incorrect_pin 1
|
|
||||||
CATCH invalid_pin flag_invalid_pin 1
|
|
||||||
CATCH update_alias flag_allow_update 1
|
|
||||||
@ -1,2 +0,0 @@
|
|||||||
Lakabu yako kamili itakuwa: {{.get_suggested_alias}}
|
|
||||||
Tafadhali weka PIN yako ili kuthibitisha:
|
|
||||||
@ -1 +1 @@
|
|||||||
The PIN you entered is invalid.The PIN must be a 4 digit number.
|
The PIN you entered is invalid.The PIN must be different from your current PIN.For help call +254757628885
|
||||||
@ -1,8 +1,3 @@
|
|||||||
LOAD reset_invalid_pin 6
|
MOUT back 0
|
||||||
RELOAD reset_invalid_pin
|
|
||||||
MOUT retry 1
|
|
||||||
MOUT quit 9
|
|
||||||
HALT
|
HALT
|
||||||
INCMP _ 1
|
INCMP _ 0
|
||||||
INCMP quit 9
|
|
||||||
INCMP . *
|
|
||||||
|
|||||||
@ -1 +1 @@
|
|||||||
PIN uliyoweka si sahihi. PIN lazima iwe nambari 4.
|
PIN mpya na udhibitisho wa PIN mpya hazilingani.Tafadhali jaribu tena.Kwa usaidizi piga simu +254757628885.
|
||||||
|
|||||||
@ -1,4 +1,3 @@
|
|||||||
LOAD authorize_account 16
|
|
||||||
LOAD reset_allow_update 0
|
LOAD reset_allow_update 0
|
||||||
MOUT profile 1
|
MOUT profile 1
|
||||||
MOUT change_language 2
|
MOUT change_language 2
|
||||||
@ -6,7 +5,6 @@ MOUT check_balance 3
|
|||||||
MOUT check_statement 4
|
MOUT check_statement 4
|
||||||
MOUT pin_options 5
|
MOUT pin_options 5
|
||||||
MOUT my_address 6
|
MOUT my_address 6
|
||||||
MOUT my_account_alias 7
|
|
||||||
MOUT back 0
|
MOUT back 0
|
||||||
HALT
|
HALT
|
||||||
INCMP main 0
|
INCMP main 0
|
||||||
@ -16,5 +14,4 @@ INCMP balances 3
|
|||||||
INCMP check_statement 4
|
INCMP check_statement 4
|
||||||
INCMP pin_management 5
|
INCMP pin_management 5
|
||||||
INCMP address 6
|
INCMP address 6
|
||||||
INCMP my_account_alias 7
|
|
||||||
INCMP . *
|
INCMP . *
|
||||||
|
|||||||
@ -1,2 +0,0 @@
|
|||||||
Current alias: {{.get_current_profile_info}}
|
|
||||||
Edit my alias:
|
|
||||||
@ -1,8 +0,0 @@
|
|||||||
LOAD get_current_profile_info 0
|
|
||||||
MAP get_current_profile_info
|
|
||||||
MOUT back 0
|
|
||||||
HALT
|
|
||||||
INCMP _ 0
|
|
||||||
LOAD request_custom_alias 0
|
|
||||||
RELOAD request_custom_alias
|
|
||||||
INCMP confirm_new_alias *
|
|
||||||
@ -1 +0,0 @@
|
|||||||
My Alias
|
|
||||||
@ -1 +0,0 @@
|
|||||||
Lakabu yangu
|
|
||||||
@ -1,2 +0,0 @@
|
|||||||
Lakabu ya sasa
|
|
||||||
Badilisha Lakabu yangu:
|
|
||||||
@ -1,8 +1,8 @@
|
|||||||
RELOAD reset_incorrect
|
RELOAD reset_allow_update
|
||||||
MOUT back 0
|
MOUT back 0
|
||||||
HALT
|
HALT
|
||||||
INCMP _ 0
|
INCMP _ 0
|
||||||
RELOAD authorize_account
|
RELOAD authorize_account
|
||||||
CATCH incorrect_pin flag_incorrect_pin 1
|
CATCH incorrect_pin flag_incorrect_pin 1
|
||||||
CATCH invalid_pin flag_invalid_pin 1
|
CATCH _ flag_allow_update 0
|
||||||
INCMP new_pin *
|
INCMP new_pin *
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
LOAD set_back 6
|
LOAD set_back 6
|
||||||
LOAD authorize_account 16
|
LOAD authorize_account 5
|
||||||
LOAD reset_allow_update 4
|
LOAD reset_allow_update 4
|
||||||
LOAD verify_new_pin 2
|
LOAD verify_new_pin 2
|
||||||
LOAD save_temporary_pin 1
|
LOAD save_temporary_pin 1
|
||||||
|
|||||||
@ -29,5 +29,4 @@ flag,flag_location_set,35,this is set when the location of the profile is set
|
|||||||
flag,flag_offerings_set,36,this is set when the offerings of the profile is set
|
flag,flag_offerings_set,36,this is set when the offerings of the profile is set
|
||||||
flag,flag_back_set,37,this is set when it is a back navigation
|
flag,flag_back_set,37,this is set when it is a back navigation
|
||||||
flag,flag_account_blocked,38,this is set when an account has been blocked after the allowed incorrect PIN attempts have been exceeded
|
flag,flag_account_blocked,38,this is set when an account has been blocked after the allowed incorrect PIN attempts have been exceeded
|
||||||
flag,flag_invalid_pin,39,this is set when the given PIN is invalid(is less than or more than 4 digits)
|
|
||||||
flag,flag_alias_set,40,this is set when an account alias has been assigned to a user
|
|
||||||
|
|||||||
|
@ -1 +0,0 @@
|
|||||||
Your alias has been updated successfully
|
|
||||||
@ -1,7 +0,0 @@
|
|||||||
LOAD confirm_new_alias 0
|
|
||||||
RELOAD confirm_new_alias
|
|
||||||
MOUT back 0
|
|
||||||
MOUT quit 9
|
|
||||||
HALT
|
|
||||||
INCMP ^ 0
|
|
||||||
INCMP quit 9
|
|
||||||
@ -1 +0,0 @@
|
|||||||
Ombi lako la kubadilisha lakabu limefanikiwa.
|
|
||||||
@ -130,8 +130,7 @@ func StringToDataTyp(str string) (DataTyp, error) {
|
|||||||
return DATA_GENDER, nil
|
return DATA_GENDER, nil
|
||||||
case "DATA_OFFERINGS":
|
case "DATA_OFFERINGS":
|
||||||
return DATA_OFFERINGS, nil
|
return DATA_OFFERINGS, nil
|
||||||
case "DATA_ACCOUNT_ALIAS":
|
|
||||||
return DATA_ACCOUNT_ALIAS, nil
|
|
||||||
default:
|
default:
|
||||||
return 0, errors.New("invalid DataTyp string")
|
return 0, errors.New("invalid DataTyp string")
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user