Compare commits

...

20 Commits

Author SHA1 Message Date
dc14480519 remove extra space 2024-09-16 17:29:27 +03:00
aaf4923f64 ensure a PIN is set before changing the language 2024-09-16 17:29:27 +03:00
e9c645bd87 added the profile info on the swa menu template 2024-09-16 17:29:27 +03:00
1be6da9139 remove new lines on templates and menus to clean up the empty spaces on the menu 2024-09-16 17:29:27 +03:00
fa2930d93a added quit menu to handle eng and swa 2024-09-16 17:29:27 +03:00
a409e292ab add the change_language functionality to the account menu 2024-09-16 17:29:27 +03:00
00c86a2850 change language 2024-09-16 17:29:27 +03:00
4daac7e90b added change_language node and templates 2024-09-16 17:29:27 +03:00
06e23565df added the SetNewLanguage function 2024-09-16 17:29:27 +03:00
b19188165b Merge pull request 'wip-menu-help' (#56) from wip-menu-help into master
Reviewed-on: #56
Reviewed-by: lash <accounts-grassrootseconomics@holbrook.no>
2024-09-16 16:21:49 +02:00
2ed9f083bb add quit with helpline info
add quit with helpline info
2024-09-16 15:17:56 +01:00
e323ffa078 Merge pull request 'Pin reset' (#59) from wip-pin-reset into master
Reviewed-on: #59
Reviewed-by: lash <accounts-grassrootseconomics@holbrook.no>
2024-09-16 16:14:52 +02:00
68de83af97 Merge pull request 'Allow setting go-vise path for asm executable in makefile' (#57) from lash/vise-make-var into master
Reviewed-on: #57
2024-09-16 15:49:58 +02:00
a3f2b23128
add pin reset templates for swahili 2024-09-16 15:17:15 +03:00
09f970db9b
navigate to main menu after successful pin reset 2024-09-16 14:59:26 +03:00
04edd90c21
fix sink issue onback option 2024-09-16 14:58:56 +03:00
a3f410875a
define temporary key value 2024-09-16 14:39:42 +03:00
3f3e98e637
add pin reset handlers 2024-09-16 14:39:01 +03:00
660f8b7aa2
add pin reset nodes 2024-09-16 14:30:47 +03:00
lash
8ae3372c36
Allow setting go-vise path for asm executable in makefile 2024-09-14 21:34:11 +01:00
76 changed files with 255 additions and 60 deletions

View File

@ -116,6 +116,7 @@ func getHandler(appFlags *asm.FlagParser, rs *resource.DbResource, userdataStore
rs.AddLocalFunc("reset_incorrect_date_format", ussdHandlers.ResetIncorrectYob)
rs.AddLocalFunc("set_reset_single_edit", ussdHandlers.SetResetSingleEdit)
rs.AddLocalFunc("initiate_transaction", ussdHandlers.InitiateTransaction)
rs.AddLocalFunc("set_new_language", ussdHandlers.SetNewLanguage)
return ussdHandlers, nil
}

View File

@ -86,6 +86,7 @@ func getHandler(appFlags *asm.FlagParser, rs *resource.DbResource, userdataStore
rs.AddLocalFunc("reset_incorrect_date_format", ussdHandlers.ResetIncorrectYob)
rs.AddLocalFunc("set_reset_single_edit", ussdHandlers.SetResetSingleEdit)
rs.AddLocalFunc("initiate_transaction", ussdHandlers.InitiateTransaction)
rs.AddLocalFunc("set_new_language", ussdHandlers.SetNewLanguage)
return ussdHandlers, nil
}

View File

@ -76,6 +76,7 @@ func getHandler(appFlags *asm.FlagParser, rs *resource.DbResource, userdataStore
rs.AddLocalFunc("reset_incorrect_date_format", ussdHandlers.ResetIncorrectYob)
rs.AddLocalFunc("set_reset_single_edit", ussdHandlers.SetResetSingleEdit)
rs.AddLocalFunc("initiate_transaction", ussdHandlers.InitiateTransaction)
rs.AddLocalFunc("set_new_language", ussdHandlers.SetNewLanguage)
return ussdHandlers, nil
}

View File

@ -71,6 +71,11 @@ func getHandler(appFlags *asm.FlagParser, rs *resource.DbResource, pe *persist.P
rs.AddLocalFunc("reset_incorrect_date_format", ussdHandlers.ResetIncorrectYob)
rs.AddLocalFunc("set_reset_single_edit", ussdHandlers.SetResetSingleEdit)
rs.AddLocalFunc("initiate_transaction", ussdHandlers.InitiateTransaction)
rs.AddLocalFunc("save_temporary_pin", ussdHandlers.SaveTemporaryPin)
rs.AddLocalFunc("verify_new_pin", ussdHandlers.VerifyNewPin)
rs.AddLocalFunc("confirm_pin_change", ussdHandlers.ConfirmPinChange)
rs.AddLocalFunc("quit_with_help",ussdHandlers.QuitWithHelp)
rs.AddLocalFunc("set_new_language", ussdHandlers.SetNewLanguage)
return ussdHandlers, nil
}

View File

@ -216,6 +216,74 @@ func (h *Handlers) SavePin(ctx context.Context, sym string, input []byte) (resou
return res, nil
}
func (h *Handlers) VerifyNewPin(ctx context.Context, sym string, input []byte) (resource.Result, error) {
res := resource.Result{}
_, ok := ctx.Value("SessionId").(string)
if !ok {
return res, fmt.Errorf("missing session")
}
flag_valid_pin, _ := h.flagManager.GetFlag("flag_valid_pin")
pinInput := string(input)
// Validate that the PIN is a 4-digit number
if isValidPIN(pinInput) {
res.FlagSet = append(res.FlagSet, flag_valid_pin)
} else {
res.FlagReset = append(res.FlagReset, flag_valid_pin)
}
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")
}
flag_pin_mismatch, _ := h.flagManager.GetFlag("flag_pin_mismatch")
store := h.userdataStore
temporaryPin, err := store.ReadEntry(ctx, sessionId, utils.DATA_TEMPORARY_PIN)
if err != nil {
return res, err
}
if bytes.Equal(temporaryPin, input) {
res.FlagReset = append(res.FlagReset, flag_pin_mismatch)
} else {
res.FlagSet = append(res.FlagSet, flag_pin_mismatch)
}
err = store.WriteEntry(ctx, sessionId, utils.DATA_ACCOUNT_PIN, []byte(temporaryPin))
if err != nil {
return res, err
}
return res, nil
}
// SetResetSingleEdit sets and resets flags to allow gradual editing of profile information.
func (h *Handlers) SetResetSingleEdit(ctx context.Context, sym string, input []byte) (resource.Result, error) {
var res resource.Result
@ -322,9 +390,6 @@ func (h *Handlers) SaveFamilyname(ctx context.Context, sym string, input []byte)
if err != nil {
return res, err
}
if err != nil {
return res, nil
}
} else {
return res, fmt.Errorf("a family name cannot be less than one character")
}
@ -481,27 +546,23 @@ func (h *Handlers) Authorize(ctx context.Context, sym string, input []byte) (res
if err != nil {
return res, err
}
if err == nil {
if len(input) == 4 {
if bytes.Equal(input, AccountPin) {
if h.st.MatchFlag(flag_account_authorized, false) {
res.FlagReset = append(res.FlagReset, flag_incorrect_pin)
res.FlagSet = append(res.FlagSet, flag_allow_update, flag_account_authorized)
} else {
res.FlagSet = append(res.FlagSet, flag_allow_update)
res.FlagReset = append(res.FlagReset, flag_account_authorized)
}
if len(input) == 4 {
if bytes.Equal(input, AccountPin) {
if h.st.MatchFlag(flag_account_authorized, false) {
res.FlagReset = append(res.FlagReset, flag_incorrect_pin)
res.FlagSet = append(res.FlagSet, flag_allow_update, flag_account_authorized)
} else {
res.FlagSet = append(res.FlagSet, flag_incorrect_pin)
res.FlagSet = append(res.FlagSet, flag_allow_update)
res.FlagReset = append(res.FlagReset, flag_account_authorized)
return res, nil
}
} else {
res.FlagSet = append(res.FlagSet, flag_incorrect_pin)
res.FlagReset = append(res.FlagReset, flag_account_authorized)
return res, nil
}
} else {
return res, nil
}
return res, nil
}
@ -569,6 +630,22 @@ func (h *Handlers) Quit(ctx context.Context, sym string, input []byte) (resource
return res, nil
}
// QuitWithHelp displays helpline information then exits the menu
func (h *Handlers) QuitWithHelp(ctx context.Context, sym string, input []byte) (resource.Result, error) {
var res resource.Result
flag_account_authorized, _ := h.flagManager.GetFlag("flag_account_authorized")
code := codeFromCtx(ctx)
l := gotext.NewLocale(translationDir, code)
l.AddDomain("default")
res.Content = l.Get("For more help,please call: 0757628885")
res.FlagReset = append(res.FlagReset, flag_account_authorized)
return res, nil
}
// VerifyYob verifies the length of the given input
func (h *Handlers) VerifyYob(ctx context.Context, sym string, input []byte) (resource.Result, error) {
var res resource.Result
@ -968,3 +1045,22 @@ func (h *Handlers) GetProfileInfo(ctx context.Context, sym string, input []byte)
return res, nil
}
// SetNewLanguage sets the new language based on user input
func (h *Handlers) SetNewLanguage(ctx context.Context, sym string, input []byte) (resource.Result, error) {
var res resource.Result
inputStr := string(input)
switch inputStr {
case "0":
res.FlagSet = append(res.FlagSet, state.FLAG_LANG)
res.Content = "eng"
case "1":
res.FlagSet = append(res.FlagSet, state.FLAG_LANG)
res.Content = "swa"
default:
}
return res, nil
}

View File

@ -22,6 +22,7 @@ const (
DATA_OFFERINGS
DATA_RECIPIENT
DATA_AMOUNT
DATA_TEMPORARY_PIN
)
func typToBytes(typ DataTyp) []byte {

View File

@ -1,10 +1,11 @@
# Variables to match files in the current directory
INPUTS = $(wildcard ./*.vis)
TXTS = $(wildcard ./*.txt.orig)
VISE_PATH := ../../go-vise
# Rule to build .bin files from .vis files
%.vis:
go run ../../go-vise/dev/asm/main.go -f pp.csv $(basename $@).vis > $(basename $@).bin
go run $(VISE_PATH)/dev/asm/main.go -f pp.csv $(basename $@).vis > $(basename $@).bin
@echo "Built $(basename $@).bin from $(basename $@).vis"
# Rule to copy .orig files to .txt

View File

@ -1 +1 @@
Rudi
Rudi

View File

@ -1 +1 @@
Balances:
Balances:

View File

@ -1 +1 @@
Salio
Salio:

View File

@ -0,0 +1 @@
Select language:

View File

@ -0,0 +1,10 @@
LOAD reset_account_authorized 0
LOAD reset_incorrect 0
CATCH incorrect_pin flag_incorrect_pin 1
CATCH pin_entry flag_account_authorized 0
MOUT english 0
MOUT kiswahili 1
HALT
INCMP language_changed 0
INCMP language_changed 1
INCMP . *

View File

@ -1 +1 @@
Badili lugha
Badili lugha

View File

@ -0,0 +1 @@
Chagua lugha:

View File

@ -1 +1 @@
Change PIN
Change PIN

View File

@ -1 +1 @@
Badili PIN
Badili PIN

View File

@ -1 +1 @@
Check statement
Check statement

View File

@ -1,2 +1 @@
Your community balance is: 0.00SRF
Your community balance is: 0.00SRF

View File

@ -1 +1 @@
Community balance
Community balance

View File

@ -0,0 +1 @@
Confirm your new PIN:

View File

@ -0,0 +1,7 @@
CATCH invalid_pin flag_valid_pin 0
MOUT back 0
HALT
INCMP _ 0
INCMP * pin_reset_success

View File

@ -0,0 +1 @@
Thibitisha PIN yako mpya:

View File

@ -1 +1 @@
Edit name
Edit name

View File

@ -1 +1 @@
Weka jina
Weka jina

View File

@ -1 +1 @@
Edit offerings
Edit offerings

View File

@ -1 +1 @@
Enter family name:
Enter family name:

View File

@ -1 +1 @@
Enter your location:
Enter your location:

View File

@ -1 +1 @@
Weka majina yako ya kwanza:
Weka majina yako ya kwanza:

View File

@ -1 +1 @@
Female
Female

View File

@ -1 +1 @@
Guard my PIN
Guard my PIN

View File

@ -1 +1 @@
Linda PIN yangu
Linda PIN yangu

View File

@ -0,0 +1,2 @@
LOAD quit_with_help 0
HALT

View File

@ -1,2 +1,2 @@
The year of birth you entered is invalid.
Please try again.
Please try again.

View File

@ -1 +1 @@
Incorrect pin
Incorrect pin

View File

@ -0,0 +1 @@
The PIN you entered is invalid.The PIN must be different from your current PIN.For help call +254757628885

View File

@ -0,0 +1,3 @@
MOUT back 0
HALT
INCMP _ 0

View File

@ -0,0 +1 @@
PIN mpya na udhibitisho wa pin mpya hazilingani.Tafadhali jaribu tena.Kwa usaidizi piga simu +254757628885.

View File

@ -0,0 +1 @@
Your language change request was successful.

View File

@ -0,0 +1,6 @@
LOAD set_new_language 6
MOUT back 0
MOUT quit 9
HALT
INCMP ^ 0
INCMP quit 9

View File

@ -0,0 +1 @@
Ombi lako la kubadilisha lugha limefanikiwa.

View File

@ -6,3 +6,7 @@ msgstr "Ombi lako limetumwa. %s atapokea %s kutoka kwa %s."
msgid "Thank you for using Sarafu. Goodbye!"
msgstr "Asante kwa kutumia huduma ya Sarafu. Kwaheri!"
msgid "For more help,please call: 0757628885"
msgstr "Kwa usaidizi zaidi,piga: 0757628885"

View File

@ -10,6 +10,6 @@ HALT
INCMP send 1
INCMP quit 2
INCMP my_account 3
INCMP quit 4
INCMP help 4
INCMP quit 9
INCMP . *

View File

@ -9,6 +9,7 @@ MOUT back 0
HALT
INCMP _ 0
INCMP edit_profile 1
INCMP change_language 2
INCMP balances 3
INCMP pin_management 5
INCMP address 6

View File

@ -1 +1 @@
Anwani yangu
Anwani yangu

View File

@ -1 +1 @@
Salio lako ni: 0.00 SRF
Salio lako ni: 0.00 SRF

View File

@ -0,0 +1 @@
Enter a new four number pin

View File

@ -0,0 +1,13 @@
LOAD authorize_account 12
RELOAD authorize_account
CATCH incorrect_pin flag_incorrect_pin 1
CATCH old_pin flag_allow_update 0
MOUT back 0
HALT
INCMP _ 0
LOAD save_temporary_pin 6
LOAD verify_new_pin 0
RELOAD save_temporary_pin
RELOAD verify_new_pin
INCMP * confirm_pin_change

View File

@ -0,0 +1,2 @@
Weka PIN mpya ya nne nambari:

View File

@ -1 +1 @@
no
no

View File

@ -1 +1 @@
la
la

View File

@ -0,0 +1 @@
Enter your old PIN

View File

@ -0,0 +1,7 @@
LOAD reset_allow_update 0
MOUT back 0
HALT
RELOAD reset_allow_update
INCMP _ 0
INCMP new_pin *

View File

@ -0,0 +1 @@
Weka PIN yako ya zamani:

View File

@ -1 +1 @@
Tafadhali weka PIN yako
Tafadhali weka PIN yako

View File

@ -1 +1 @@
PIN Management
PIN Management

View File

@ -4,3 +4,5 @@ MOUT guard_pin 3
MOUT back 0
HALT
INCMP _ 0
INCMP old_pin 1

View File

@ -0,0 +1 @@
The PIN is not a match. Try again

View File

@ -0,0 +1,6 @@
MOUT retry 1
MOUT quit 9
HALT
INCMP confirm_pin_change 1
INCMP quit 9

View File

@ -0,0 +1 @@
Your PIN change request has been successful

View File

@ -0,0 +1,10 @@
LOAD confirm_pin_change 0
RELOAD confirm_pin_change
CATCH pin_reset_mismatch flag_pin_mismatch 1
MOUT back 0
MOUT quit 9
HALT
INCMP main 0
INCMP quit 9

View File

@ -0,0 +1 @@
Ombi lako la kubadili PIN limefanikiwa

View File

@ -1 +1 @@
Profile
Profile

View File

@ -1 +1 @@
Wasifu wangu
Wasifu wangu

View File

@ -0,0 +1 @@
Quit

View File

@ -0,0 +1 @@
Ondoka

View File

@ -1 +1 @@
Badili PIN ya mwenzio
Badili PIN ya mwenzio

View File

@ -1 +1 @@
Enter recipient's phone number:
Enter recipient's phone number:

View File

@ -1,2 +1,2 @@
{{.get_recipient}} will receive {{.validate_amount}} from {{.get_sender}}
Please enter your PIN to confirm:
Please enter your PIN to confirm:

View File

@ -1 +1 @@
Unspecified
Unspecified

View File

@ -1 +1 @@
Profile updated successfully
Profile updated successfully

View File

@ -1 +1 @@
Akaunti imeupdatiwa
Akaunti imeupdatiwa

View File

@ -1,2 +1,2 @@
My profile:
{{.get_profile_info}}
My profile:
{{.get_profile_info}}

View File

@ -1 +1,2 @@
Wasifu wangu
Wasifu wangu:
{{.get_profile_info}}

View File

@ -1 +1 @@
Angalia Wasifu
Angalia Wasifu

View File

@ -1 +1 @@
yes
yes

View File

@ -1 +1 @@
ndio
ndio