Compare commits

..

No commits in common. "37809a05b4bdf4f22a2f03c7286816df51b239a9" and "617a6101aac610335ef819e7eb03c701bc195636" have entirely different histories.

12 changed files with 39 additions and 82 deletions

View File

@ -10,7 +10,6 @@ import (
"net/http" "net/http"
"os" "os"
"path" "path"
"regexp"
"time" "time"
"git.defalsify.org/vise.git/cache" "git.defalsify.org/vise.git/cache"
@ -35,7 +34,6 @@ const (
USERFLAG_QUERYPIN USERFLAG_QUERYPIN
USERFLAG_VALIDPIN USERFLAG_VALIDPIN
USERFLAG_INVALIDPIN USERFLAG_INVALIDPIN
USERFLAG_INCORRECTDATEFORMAT
) )
const ( const (
@ -89,7 +87,7 @@ func codeFromCtx(ctx context.Context) string {
return code return code
} }
func (fsd *fsData) save_firstname(cxt context.Context, sym string, input []byte) (resource.Result, error) { func (fsd *fsData) saveFirstName(cxt context.Context, sym string, input []byte) (resource.Result, error) {
res := resource.Result{} res := resource.Result{}
fp := fsd.path + "_data" fp := fsd.path + "_data"
@ -120,7 +118,7 @@ func (fsd *fsData) save_firstname(cxt context.Context, sym string, input []byte)
return res, nil return res, nil
} }
func (fsd *fsData) save_familyname(cxt context.Context, sym string, input []byte) (resource.Result, error) { func (fsd *fsData) saveFamilyName(cxt context.Context, sym string, input []byte) (resource.Result, error) {
res := resource.Result{} res := resource.Result{}
fp := fsd.path + "_data" fp := fsd.path + "_data"
@ -151,7 +149,7 @@ func (fsd *fsData) save_familyname(cxt context.Context, sym string, input []byte
return res, nil return res, nil
} }
func (fsd *fsData) save_yob(cxt context.Context, sym string, input []byte) (resource.Result, error) { func (fsd *fsData) saveYOB(cxt context.Context, sym string, input []byte) (resource.Result, error) {
res := resource.Result{} res := resource.Result{}
fp := fsd.path + "_data" fp := fsd.path + "_data"
jsonData, err := os.ReadFile(fp) jsonData, err := os.ReadFile(fp)
@ -180,7 +178,7 @@ func (fsd *fsData) save_yob(cxt context.Context, sym string, input []byte) (reso
return res, nil return res, nil
} }
func (fsd *fsData) save_location(cxt context.Context, sym string, input []byte) (resource.Result, error) { func (fsd *fsData) saveLocation(cxt context.Context, sym string, input []byte) (resource.Result, error) {
res := resource.Result{} res := resource.Result{}
fp := fsd.path + "_data" fp := fsd.path + "_data"
jsonData, err := os.ReadFile(fp) jsonData, err := os.ReadFile(fp)
@ -210,7 +208,7 @@ func (fsd *fsData) save_location(cxt context.Context, sym string, input []byte)
return res, nil return res, nil
} }
func (fsd *fsData) save_gender(ctx context.Context, sym string, input []byte) (resource.Result, error) { func (fsd *fsData) saveGender(ctx context.Context, sym string, input []byte) (resource.Result, error) {
res := resource.Result{} res := resource.Result{}
fp := fsd.path + "_data" fp := fsd.path + "_data"
jsonData, err := os.ReadFile(fp) jsonData, err := os.ReadFile(fp)
@ -233,6 +231,7 @@ func (fsd *fsData) save_gender(ctx context.Context, sym string, input []byte) (r
case "3": case "3":
gender = "Other" gender = "Other"
} }
fmt.Println("gender", gender)
accountData["Gender"] = gender accountData["Gender"] = gender
updatedJsonData, err := json.Marshal(accountData) updatedJsonData, err := json.Marshal(accountData)
if err != nil { if err != nil {
@ -247,7 +246,7 @@ func (fsd *fsData) save_gender(ctx context.Context, sym string, input []byte) (r
return res, nil return res, nil
} }
func (fsd *fsData) save_offerings(ctx context.Context, sym string, input []byte) (resource.Result, error) { func (fsd *fsData) saveOfferings(ctx context.Context, sym string, input []byte) (resource.Result, error) {
res := resource.Result{} res := resource.Result{}
fp := fsd.path + "_data" fp := fsd.path + "_data"
jsonData, err := os.ReadFile(fp) jsonData, err := os.ReadFile(fp)
@ -274,7 +273,7 @@ func (fsd *fsData) save_offerings(ctx context.Context, sym string, input []byte)
return res, nil return res, nil
} }
func (fsd *fsData) set_language(ctx context.Context, sym string, input []byte) (resource.Result, error) { func (fsd *fsData) SetLanguageSelected(ctx context.Context, sym string, input []byte) (resource.Result, error) {
inputStr := string(input) inputStr := string(input)
res := resource.Result{} res := resource.Result{}
switch inputStr { switch inputStr {
@ -328,19 +327,19 @@ func (fsd *fsData) create_account(ctx context.Context, sym string, input []byte)
return res, err return res, err
} }
func (fsd *fsData) reset_unlock_for_update(ctx context.Context, sym string, input []byte) (resource.Result, error) { func (fsd *fsData) resetUnlockForUpdate(ctx context.Context, sym string, input []byte) (resource.Result, error) {
res := resource.Result{} res := resource.Result{}
res.FlagReset = append(res.FlagReset, USERFLAG_UNLOCKFORUPDATE) res.FlagReset = append(res.FlagReset, USERFLAG_UNLOCKFORUPDATE)
return res, nil return res, nil
} }
func (fsd *fsData) reset_account_unlocked(ctx context.Context, sym string, input []byte) (resource.Result, error) { func (fsd *fsData) resetAccountUnlocked(ctx context.Context, sym string, input []byte) (resource.Result, error) {
res := resource.Result{} res := resource.Result{}
res.FlagReset = append(res.FlagReset, USERFLAG_ACCOUNT_UNLOCKED) res.FlagReset = append(res.FlagReset, USERFLAG_ACCOUNT_UNLOCKED)
return res, nil return res, nil
} }
func (fsd *fsData) check_identifier(ctx context.Context, sym string, input []byte) (resource.Result, error) { func (fsd *fsData) checkIdentifier(ctx context.Context, sym string, input []byte) (resource.Result, error) {
res := resource.Result{} res := resource.Result{}
fp := fsd.path + "_data" fp := fsd.path + "_data"
@ -360,7 +359,7 @@ func (fsd *fsData) check_identifier(ctx context.Context, sym string, input []byt
return res, nil return res, nil
} }
func (fsd *fsData) unlock(ctx context.Context, sym string, input []byte) (resource.Result, error) { func (fsd *fsData) unLock(ctx context.Context, sym string, input []byte) (resource.Result, error) {
res := resource.Result{} res := resource.Result{}
pin := string(input) pin := string(input)
fp := fsd.path + "_data" fp := fsd.path + "_data"
@ -383,8 +382,6 @@ func (fsd *fsData) unlock(ctx context.Context, sym string, input []byte) (resour
return res, nil return res, nil
} }
if fsd.st.MatchFlag(USERFLAG_ACCOUNT_UNLOCKED, false) { if fsd.st.MatchFlag(USERFLAG_ACCOUNT_UNLOCKED, false) {
res.FlagReset = append(res.FlagReset, USERFLAG_INCORRECTPIN)
res.FlagSet = append(res.FlagSet, USERFLAG_UNLOCKFORUPDATE)
res.FlagSet = append(res.FlagSet, USERFLAG_ACCOUNT_UNLOCKED) res.FlagSet = append(res.FlagSet, USERFLAG_ACCOUNT_UNLOCKED)
} else { } else {
res.FlagReset = append(res.FlagReset, USERFLAG_ACCOUNT_UNLOCKED) res.FlagReset = append(res.FlagReset, USERFLAG_ACCOUNT_UNLOCKED)
@ -393,7 +390,7 @@ func (fsd *fsData) unlock(ctx context.Context, sym string, input []byte) (resour
return res, nil return res, nil
} }
func (fsd *fsData) reset_incorrect_pin(ctx context.Context, sym string, input []byte) (resource.Result, error) { func (fsd *fsData) ResetIncorrectPin(ctx context.Context, sym string, input []byte) (resource.Result, error) {
res := resource.Result{} res := resource.Result{}
isIncorrectPinSet := fsd.st.MatchFlag(USERFLAG_INCORRECTPIN, true) isIncorrectPinSet := fsd.st.MatchFlag(USERFLAG_INCORRECTPIN, true)
if isIncorrectPinSet { if isIncorrectPinSet {
@ -404,7 +401,10 @@ func (fsd *fsData) reset_incorrect_pin(ctx context.Context, sym string, input []
return res, nil return res, nil
} }
func (fsd *fsData) ShowUpdateSuccess(ctx context.Context, sym string, input []byte) (resource.Result, error) {
res := resource.Result{}
return res, nil
}
func (fsd *fsData) check_account_status(ctx context.Context, sym string, input []byte) (resource.Result, error) { func (fsd *fsData) check_account_status(ctx context.Context, sym string, input []byte) (resource.Result, error) {
res := resource.Result{} res := resource.Result{}
@ -507,28 +507,7 @@ func (fsd *fsData) quit(ctx context.Context, sym string, input []byte) (resource
return res, nil return res, nil
} }
func (fsd *fsData) verify_yob(ctx context.Context, sym string, input []byte) (resource.Result, error) { func (fsd *fsData) checkBalance(ctx context.Context, sym string, input []byte) (resource.Result, error) {
res := resource.Result{}
date := string(input)
dateRegex := regexp.MustCompile(`^\d{2}/\d{2}/\d{4}$`)
isCorrectFormat := dateRegex.MatchString(date)
if !isCorrectFormat {
res.FlagSet = append(res.FlagSet, USERFLAG_INCORRECTDATEFORMAT)
} else {
res.FlagReset = append(res.FlagReset, USERFLAG_INCORRECTDATEFORMAT)
}
return res, nil
}
func (fsd *fsData) reser_incorrect_yob(ctx context.Context, sym string, input []byte) (resource.Result, error) {
res := resource.Result{}
res.FlagReset = append(res.FlagReset, USERFLAG_INCORRECTDATEFORMAT)
return res, nil
}
func (fsd *fsData) check_balance(ctx context.Context, sym string, input []byte) (resource.Result, error) {
res := resource.Result{} res := resource.Result{}
fp := fsd.path + "_data" fp := fsd.path + "_data"
@ -751,7 +730,7 @@ func (fsd *fsData) get_recipient(ctx context.Context, sym string, input []byte)
return res, nil return res, nil
} }
func (fsd *fsData) get_profile_info(ctx context.Context, sym string, input []byte) (resource.Result, error) { func (fsd *fsData) getProfileInfo(ctx context.Context, sym string, input []byte) (resource.Result, error) {
res := resource.Result{} res := resource.Result{}
fp := fsd.path + "_data" fp := fsd.path + "_data"
@ -796,7 +775,7 @@ func (fsd *fsData) get_sender(ctx context.Context, sym string, input []byte) (re
return res, nil return res, nil
} }
func (fsd *fsData) quit_with_balance(ctx context.Context, sym string, input []byte) (resource.Result, error) { func (fsd *fsData) quitWithBalance(ctx context.Context, sym string, input []byte) (resource.Result, error) {
res := resource.Result{} res := resource.Result{}
fp := fsd.path + "_data" fp := fsd.path + "_data"
@ -947,15 +926,15 @@ func main() {
path: fp, path: fp,
st: &st, st: &st,
} }
rfs.AddLocalFunc("select_language", fs.set_language) rfs.AddLocalFunc("select_language", fs.SetLanguageSelected)
rfs.AddLocalFunc("create_account", fs.create_account) rfs.AddLocalFunc("create_account", fs.create_account)
rfs.AddLocalFunc("save_pin", fs.save_pin) rfs.AddLocalFunc("save_pin", fs.save_pin)
rfs.AddLocalFunc("verify_pin", fs.verify_pin) rfs.AddLocalFunc("verify_pin", fs.verify_pin)
rfs.AddLocalFunc("check_identifier", fs.check_identifier) rfs.AddLocalFunc("check_identifier", fs.checkIdentifier)
rfs.AddLocalFunc("check_account_status", fs.check_account_status) rfs.AddLocalFunc("check_account_status", fs.check_account_status)
rfs.AddLocalFunc("unlock_account", fs.unlock) rfs.AddLocalFunc("unlock_account", fs.unLock)
rfs.AddLocalFunc("quit", fs.quit) rfs.AddLocalFunc("quit", fs.quit)
rfs.AddLocalFunc("check_balance", fs.check_balance) rfs.AddLocalFunc("check_balance", fs.checkBalance)
rfs.AddLocalFunc("validate_recipient", fs.validate_recipient) rfs.AddLocalFunc("validate_recipient", fs.validate_recipient)
rfs.AddLocalFunc("transaction_reset", fs.transaction_reset) rfs.AddLocalFunc("transaction_reset", fs.transaction_reset)
rfs.AddLocalFunc("max_amount", fs.max_amount) rfs.AddLocalFunc("max_amount", fs.max_amount)
@ -963,19 +942,18 @@ func main() {
rfs.AddLocalFunc("reset_transaction_amount", fs.reset_transaction_amount) rfs.AddLocalFunc("reset_transaction_amount", fs.reset_transaction_amount)
rfs.AddLocalFunc("get_recipient", fs.get_recipient) rfs.AddLocalFunc("get_recipient", fs.get_recipient)
rfs.AddLocalFunc("get_sender", fs.get_sender) rfs.AddLocalFunc("get_sender", fs.get_sender)
rfs.AddLocalFunc("reset_incorrect", fs.reset_incorrect_pin) rfs.AddLocalFunc("reset_incorrect", fs.ResetIncorrectPin)
rfs.AddLocalFunc("save_firstname", fs.save_firstname) rfs.AddLocalFunc("save_firstname", fs.saveFirstName)
rfs.AddLocalFunc("save_familyname", fs.save_familyname) rfs.AddLocalFunc("save_familyname", fs.saveFamilyName)
rfs.AddLocalFunc("save_gender", fs.save_gender) rfs.AddLocalFunc("save_gender", fs.saveGender)
rfs.AddLocalFunc("save_location", fs.save_location) rfs.AddLocalFunc("save_location", fs.saveLocation)
rfs.AddLocalFunc("save_yob", fs.save_yob) rfs.AddLocalFunc("save_yob", fs.saveYOB)
rfs.AddLocalFunc("save_offerings", fs.save_offerings) rfs.AddLocalFunc("save_offerings", fs.saveOfferings)
rfs.AddLocalFunc("quit_with_balance", fs.quit_with_balance) rfs.AddLocalFunc("quit_with_balance", fs.quitWithBalance)
rfs.AddLocalFunc("reset_unlocked", fs.reset_account_unlocked) rfs.AddLocalFunc("show_update_success", fs.ShowUpdateSuccess)
rfs.AddLocalFunc("reset_unlock_for_update", fs.reset_unlock_for_update) rfs.AddLocalFunc("reset_unlocked", fs.resetAccountUnlocked)
rfs.AddLocalFunc("get_profile_info", fs.get_profile_info) rfs.AddLocalFunc("reset_unlock_for_update", fs.resetUnlockForUpdate)
rfs.AddLocalFunc("verify_yob", fs.verify_yob) rfs.AddLocalFunc("get_profile_info", fs.getProfileInfo)
rfs.AddLocalFunc("reset_incorrect_date_format", fs.reser_incorrect_yob)
cont, err := en.Init(ctx) cont, err := en.Init(ctx)
en.SetDebugger(engine.NewSimpleDebug(nil)) en.SetDebugger(engine.NewSimpleDebug(nil))

View File

@ -1,6 +1,5 @@
LOAD check_identifier 0 LOAD check_identifier 0
RELOAD check_identifier RELOAD check_identifier
MAP check_identifier MAP check_identifier
MOUT quit 9
HALT HALT
INCMP quit 9 MOVE quit

View File

@ -12,5 +12,6 @@ INCMP _ 0
INCMP enter_name 1 INCMP enter_name 1
INCMP select_gender 2 INCMP select_gender 2
INCMP enter_yob 3 INCMP enter_yob 3
INCMP enter_loca 4 INCMP enter_location 4
INCMP enter_offerings 5
INCMP view_profile 6 INCMP view_profile 6

View File

@ -1,9 +1,5 @@
CATCH incorrect_date_format 21 1
LOAD save_yob 0 LOAD save_yob 0
MOUT back 0 MOUT back 0
HALT HALT
INCMP _ 0 INCMP _ 0
INCMP enter_offerings * INCMP enter_offerings *

View File

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

View File

@ -2,5 +2,4 @@ LOAD save_gender 0
MOUT back 0 MOUT back 0
HALT HALT
INCMP _ 0 INCMP _ 0
LOAD verify_yob 8
INCMP enter_location * INCMP enter_location *

View File

@ -1,2 +0,0 @@
Unsuported date format
Please provide date format as 12/01/1972

View File

@ -1,6 +0,0 @@
LOAD reset_incorrect_date_format 8
MOUT retry 1
MOUT quit 9
HALT
INCMP enter_yob 1
INCMP quit 9

View File

@ -1,5 +1,3 @@
MOUT back 0 MOUT back 0
MOUT quit 9
HALT HALT
INCMP ^ 0 INCMP ^ 0
INCMP quit 9