Compare commits
No commits in common. "5b5352f569b2469b0dc07c3e0dab2139e23fee8f" and "99fcb9706e696cba1264d2e43456daf0d73eb8be" have entirely different histories.
5b5352f569
...
99fcb9706e
@ -72,8 +72,6 @@ func getHandler(appFlags *asm.FlagParser, rs *resource.DbResource, pe *persist.P
|
|||||||
rs.AddLocalFunc("set_reset_single_edit", ussdHandlers.SetResetSingleEdit)
|
rs.AddLocalFunc("set_reset_single_edit", ussdHandlers.SetResetSingleEdit)
|
||||||
rs.AddLocalFunc("initiate_transaction", ussdHandlers.InitiateTransaction)
|
rs.AddLocalFunc("initiate_transaction", ussdHandlers.InitiateTransaction)
|
||||||
rs.AddLocalFunc("quit_with_help", ussdHandlers.QuitWithHelp)
|
rs.AddLocalFunc("quit_with_help", ussdHandlers.QuitWithHelp)
|
||||||
rs.AddLocalFunc("save_temporary_pin", ussdHandlers.SaveTemporaryPin)
|
|
||||||
rs.AddLocalFunc("confirm_pin_change", ussdHandlers.ConfirmPinChange)
|
|
||||||
|
|
||||||
return ussdHandlers, nil
|
return ussdHandlers, nil
|
||||||
}
|
}
|
||||||
|
|||||||
@ -192,48 +192,6 @@ func (h *Handlers) CreateAccount(ctx context.Context, sym string, input []byte)
|
|||||||
return res, nil
|
return res, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h *Handlers) SaveTemporaryPin(ctx context.Context, sym string, input []byte) (resource.Result, error) {
|
|
||||||
var res resource.Result
|
|
||||||
var err error
|
|
||||||
|
|
||||||
sessionId, ok := ctx.Value("SessionId").(string)
|
|
||||||
if !ok {
|
|
||||||
return res, fmt.Errorf("missing session")
|
|
||||||
}
|
|
||||||
flag_incorrect_pin, _ := h.flagManager.GetFlag("flag_incorrect_pin")
|
|
||||||
|
|
||||||
accountPIN := string(input)
|
|
||||||
// Validate that the PIN is a 4-digit number
|
|
||||||
if !isValidPIN(accountPIN) {
|
|
||||||
res.FlagSet = append(res.FlagSet, flag_incorrect_pin)
|
|
||||||
return res, nil
|
|
||||||
}
|
|
||||||
store := h.userdataStore
|
|
||||||
err = store.WriteEntry(ctx, sessionId, utils.DATA_TEMPORARY_PIN, []byte(accountPIN))
|
|
||||||
if err != nil {
|
|
||||||
return res, err
|
|
||||||
}
|
|
||||||
return res, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (h *Handlers) ConfirmPinChange(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
|
|
||||||
temporaryPin, err := store.ReadEntry(ctx, sessionId, utils.DATA_TEMPORARY_PIN)
|
|
||||||
if err != nil {
|
|
||||||
return res, err
|
|
||||||
}
|
|
||||||
err = store.WriteEntry(ctx, sessionId, utils.DATA_ACCOUNT_PIN, []byte(temporaryPin))
|
|
||||||
if err != nil {
|
|
||||||
return res, err
|
|
||||||
}
|
|
||||||
return res, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// SavePin persists the user's PIN choice into the filesystem
|
// SavePin persists the user's PIN choice into the filesystem
|
||||||
func (h *Handlers) SavePin(ctx context.Context, sym string, input []byte) (resource.Result, error) {
|
func (h *Handlers) SavePin(ctx context.Context, sym string, input []byte) (resource.Result, error) {
|
||||||
var res resource.Result
|
var res resource.Result
|
||||||
@ -302,19 +260,15 @@ func (h *Handlers) VerifyPin(ctx context.Context, sym string, input []byte) (res
|
|||||||
if !ok {
|
if !ok {
|
||||||
return res, fmt.Errorf("missing session")
|
return res, fmt.Errorf("missing session")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//AccountPin, _ := utils.ReadEntry(ctx, h.userdataStore, sessionId, utils.DATA_ACCOUNT_PIN)
|
||||||
store := h.userdataStore
|
store := h.userdataStore
|
||||||
AccountPin, err := store.ReadEntry(ctx, sessionId, utils.DATA_ACCOUNT_PIN)
|
AccountPin, err := store.ReadEntry(ctx, sessionId, utils.DATA_ACCOUNT_PIN)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return res, err
|
return res, err
|
||||||
}
|
}
|
||||||
TemporaryPIn, err := store.ReadEntry(ctx, sessionId, utils.DATA_TEMPORARY_PIN)
|
|
||||||
if err != nil {
|
|
||||||
if !db.IsNotFound(err) {
|
|
||||||
return res, err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if bytes.Equal(input, AccountPin) || bytes.Equal(input, TemporaryPIn) {
|
if bytes.Equal(input, AccountPin) {
|
||||||
res.FlagSet = []uint32{flag_valid_pin}
|
res.FlagSet = []uint32{flag_valid_pin}
|
||||||
res.FlagReset = []uint32{flag_pin_mismatch}
|
res.FlagReset = []uint32{flag_pin_mismatch}
|
||||||
res.FlagSet = append(res.FlagSet, flag_pin_set)
|
res.FlagSet = append(res.FlagSet, flag_pin_set)
|
||||||
@ -615,6 +569,7 @@ func (h *Handlers) Quit(ctx context.Context, sym string, input []byte) (resource
|
|||||||
return res, nil
|
return res, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Quit displays the Thank you message and exits the menu
|
// Quit displays the Thank you message and exits the menu
|
||||||
func (h *Handlers) QuitWithHelp(ctx context.Context, sym string, input []byte) (resource.Result, error) {
|
func (h *Handlers) QuitWithHelp(ctx context.Context, sym string, input []byte) (resource.Result, error) {
|
||||||
var res resource.Result
|
var res resource.Result
|
||||||
|
|||||||
@ -22,7 +22,6 @@ const (
|
|||||||
DATA_OFFERINGS
|
DATA_OFFERINGS
|
||||||
DATA_RECIPIENT
|
DATA_RECIPIENT
|
||||||
DATA_AMOUNT
|
DATA_AMOUNT
|
||||||
DATA_TEMPORARY_PIN
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func typToBytes(typ DataTyp) []byte {
|
func typToBytes(typ DataTyp) []byte {
|
||||||
|
|||||||
@ -1 +0,0 @@
|
|||||||
Confirm your new PIN:
|
|
||||||
@ -1,7 +0,0 @@
|
|||||||
LOAD verify_pin 0
|
|
||||||
MOUT back 0
|
|
||||||
HALT
|
|
||||||
RELOAD verify_pin
|
|
||||||
CATCH create_pin_mismatch flag_pin_mismatch 1
|
|
||||||
MOVE pin_reset_success
|
|
||||||
INCMP _ 0
|
|
||||||
@ -1 +0,0 @@
|
|||||||
The PIN you entered is invalid.The PIN must be different from your current PIN.For help call +254757628885
|
|
||||||
@ -1,4 +0,0 @@
|
|||||||
MOUT back 0
|
|
||||||
HALT
|
|
||||||
INCMP _ 0
|
|
||||||
|
|
||||||
@ -1,7 +1,3 @@
|
|||||||
LOAD save_temporary_pin 0
|
|
||||||
MOUT back 0
|
MOUT back 0
|
||||||
HALT
|
HALT
|
||||||
RELOAD save_temporary_pin
|
|
||||||
CATCH invalid_pin flag_incorrect_pin 1
|
|
||||||
INCMP _ 0
|
INCMP _ 0
|
||||||
MOVE confirm_pin_change
|
|
||||||
|
|||||||
@ -1 +0,0 @@
|
|||||||
Your PIN change request has been successful
|
|
||||||
@ -1,6 +0,0 @@
|
|||||||
LOAD confirm_pin_change 0
|
|
||||||
MOUT back 0
|
|
||||||
MOUT quit 9
|
|
||||||
HALT
|
|
||||||
INCMP _ 0
|
|
||||||
INCMP quit 9
|
|
||||||
Loading…
Reference in New Issue
Block a user