Compare commits
4 Commits
99fcb9706e
...
5b5352f569
Author | SHA1 | Date | |
---|---|---|---|
5b5352f569 | |||
e3e8bfe85c | |||
10c917b6da | |||
7c7150b103 |
@ -72,6 +72,8 @@ 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,6 +192,48 @@ 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
|
||||||
@ -260,15 +302,19 @@ 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) {
|
if bytes.Equal(input, AccountPin) || bytes.Equal(input, TemporaryPIn) {
|
||||||
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)
|
||||||
@ -569,7 +615,6 @@ 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,6 +22,7 @@ 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
services/registration/confirm_pin_change
Normal file
1
services/registration/confirm_pin_change
Normal file
@ -0,0 +1 @@
|
|||||||
|
Confirm your new PIN:
|
7
services/registration/confirm_pin_change.vis
Normal file
7
services/registration/confirm_pin_change.vis
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
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
services/registration/invalid_pin
Normal file
1
services/registration/invalid_pin
Normal file
@ -0,0 +1 @@
|
|||||||
|
The PIN you entered is invalid.The PIN must be different from your current PIN.For help call +254757628885
|
4
services/registration/invalid_pin.vis
Normal file
4
services/registration/invalid_pin.vis
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
MOUT back 0
|
||||||
|
HALT
|
||||||
|
INCMP _ 0
|
||||||
|
|
@ -1,3 +1,7 @@
|
|||||||
|
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
services/registration/pin_reset_success
Normal file
1
services/registration/pin_reset_success
Normal file
@ -0,0 +1 @@
|
|||||||
|
Your PIN change request has been successful
|
6
services/registration/pin_reset_success.vis
Normal file
6
services/registration/pin_reset_success.vis
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
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