|
|
@ -20,7 +20,7 @@ import (
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
var (
|
|
|
|
var (
|
|
|
|
scriptDir = path.Join( "services", "registration")
|
|
|
|
scriptDir = path.Join("services", "registration")
|
|
|
|
translationDir = path.Join(scriptDir, "locale")
|
|
|
|
translationDir = path.Join(scriptDir, "locale")
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
@ -44,7 +44,7 @@ type Handlers struct {
|
|
|
|
fs *FSData
|
|
|
|
fs *FSData
|
|
|
|
accountCreator AccountCreator
|
|
|
|
accountCreator AccountCreator
|
|
|
|
accountFileHandler utils.AccountFileHandlerInterface
|
|
|
|
accountFileHandler utils.AccountFileHandlerInterface
|
|
|
|
accountService server.AccountServiceInterface
|
|
|
|
accountService server.AccountServiceInterface
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func NewHandlers(path string, st *state.State) *Handlers {
|
|
|
|
func NewHandlers(path string, st *state.State) *Handlers {
|
|
|
@ -55,10 +55,12 @@ func NewHandlers(path string, st *state.State) *Handlers {
|
|
|
|
},
|
|
|
|
},
|
|
|
|
accountFileHandler: utils.NewAccountFileHandler(path + "_data"),
|
|
|
|
accountFileHandler: utils.NewAccountFileHandler(path + "_data"),
|
|
|
|
accountCreator: &ServerAccountCreator{},
|
|
|
|
accountCreator: &ServerAccountCreator{},
|
|
|
|
accountService: &server.AccountService{},
|
|
|
|
accountService: &server.AccountService{},
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Define the regex pattern as a constant
|
|
|
|
// Define the regex pattern as a constant
|
|
|
|
const pinPattern = `^\d{4}$`
|
|
|
|
const pinPattern = `^\d{4}$`
|
|
|
|
|
|
|
|
|
|
|
@ -158,19 +160,19 @@ func (h *Handlers) SavePin(ctx context.Context, sym string, input []byte) (resou
|
|
|
|
return res, nil
|
|
|
|
return res, nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//SetResetSingleEdit sets and resets flags to allow gradual editing of profile information.
|
|
|
|
// 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) {
|
|
|
|
func (h *Handlers) SetResetSingleEdit(ctx context.Context, sym string, input []byte) (resource.Result, error) {
|
|
|
|
res := resource.Result{}
|
|
|
|
res := resource.Result{}
|
|
|
|
menuOption := string(input)
|
|
|
|
menuOption := string(input)
|
|
|
|
switch menuOption {
|
|
|
|
switch menuOption {
|
|
|
|
case "2":
|
|
|
|
case "2":
|
|
|
|
res.FlagReset = append(res.FlagSet, models.USERFLAG_UNLOCKFORUPDATE)
|
|
|
|
res.FlagReset = append(res.FlagSet, models.USERFLAG_ALLOW_UPDATE)
|
|
|
|
res.FlagSet = append(res.FlagSet, models.USERFLAG_SINGLE_EDIT)
|
|
|
|
res.FlagSet = append(res.FlagSet, models.USERFLAG_SINGLE_EDIT)
|
|
|
|
case "3":
|
|
|
|
case "3":
|
|
|
|
res.FlagReset = append(res.FlagSet, models.USERFLAG_UNLOCKFORUPDATE)
|
|
|
|
res.FlagReset = append(res.FlagSet, models.USERFLAG_ALLOW_UPDATE)
|
|
|
|
res.FlagSet = append(res.FlagSet, models.USERFLAG_SINGLE_EDIT)
|
|
|
|
res.FlagSet = append(res.FlagSet, models.USERFLAG_SINGLE_EDIT)
|
|
|
|
case "4":
|
|
|
|
case "4":
|
|
|
|
res.FlagReset = append(res.FlagSet, models.USERFLAG_UNLOCKFORUPDATE)
|
|
|
|
res.FlagReset = append(res.FlagSet, models.USERFLAG_ALLOW_UPDATE)
|
|
|
|
res.FlagSet = append(res.FlagSet, models.USERFLAG_SINGLE_EDIT)
|
|
|
|
res.FlagSet = append(res.FlagSet, models.USERFLAG_SINGLE_EDIT)
|
|
|
|
default:
|
|
|
|
default:
|
|
|
|
res.FlagReset = append(res.FlagReset, models.USERFLAG_SINGLE_EDIT)
|
|
|
|
res.FlagReset = append(res.FlagReset, models.USERFLAG_SINGLE_EDIT)
|
|
|
@ -317,7 +319,7 @@ func (h *Handlers) SaveGender(ctx context.Context, sym string, input []byte) (re
|
|
|
|
case "2":
|
|
|
|
case "2":
|
|
|
|
gender = "Female"
|
|
|
|
gender = "Female"
|
|
|
|
case "3":
|
|
|
|
case "3":
|
|
|
|
gender = "Other"
|
|
|
|
gender = "Unspecified"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
accountData["Gender"] = gender
|
|
|
|
accountData["Gender"] = gender
|
|
|
|
|
|
|
|
|
|
|
@ -350,17 +352,17 @@ func (h *Handlers) SaveOfferings(ctx context.Context, sym string, input []byte)
|
|
|
|
return res, nil
|
|
|
|
return res, nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//ResetUnlockForUpdate resets the unlockforupdate flag to correctly show appropriate nodes as a user provides the profile data.
|
|
|
|
// ResetAllowUpdate resets the allowupdate flag that allows a user to update profile data.
|
|
|
|
func (h *Handlers) ResetUnlockForUpdate(ctx context.Context, sym string, input []byte) (resource.Result, error) {
|
|
|
|
func (h *Handlers) ResetAllowUpdate(ctx context.Context, sym string, input []byte) (resource.Result, error) {
|
|
|
|
res := resource.Result{}
|
|
|
|
res := resource.Result{}
|
|
|
|
res.FlagReset = append(res.FlagReset, models.USERFLAG_UNLOCKFORUPDATE)
|
|
|
|
res.FlagReset = append(res.FlagReset, models.USERFLAG_ALLOW_UPDATE)
|
|
|
|
return res, nil
|
|
|
|
return res, nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//ResetAccountUnlocked locks an account that had already been unlocked.
|
|
|
|
// ResetAccountAuthorized resets the account authorization flag after a successful PIN entry.
|
|
|
|
func (h *Handlers) ResetAccountUnlocked(ctx context.Context, sym string, input []byte) (resource.Result, error) {
|
|
|
|
func (h *Handlers) ResetAccountAuthorized(ctx context.Context, sym string, input []byte) (resource.Result, error) {
|
|
|
|
res := resource.Result{}
|
|
|
|
res := resource.Result{}
|
|
|
|
res.FlagReset = append(res.FlagReset, models.USERFLAG_ACCOUNT_UNLOCKED)
|
|
|
|
res.FlagReset = append(res.FlagReset, models.USERFLAG_ACCOUNT_AUTHORIZED)
|
|
|
|
return res, nil
|
|
|
|
return res, nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -378,9 +380,9 @@ func (h *Handlers) CheckIdentifier(ctx context.Context, sym string, input []byte
|
|
|
|
return res, nil
|
|
|
|
return res, nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Unlock attempts to unlock the next sequential nodes by verifying the provided PIN against the already set PIN.
|
|
|
|
// Authorize attempts to unlock the next sequential nodes by verifying the provided PIN against the already set PIN.
|
|
|
|
// It sets the required flags that control the flow.
|
|
|
|
// It sets the required flags that control the flow.
|
|
|
|
func (h *Handlers) Unlock(ctx context.Context, sym string, input []byte) (resource.Result, error) {
|
|
|
|
func (h *Handlers) Authorize(ctx context.Context, sym string, input []byte) (resource.Result, error) {
|
|
|
|
res := resource.Result{}
|
|
|
|
res := resource.Result{}
|
|
|
|
pin := string(input)
|
|
|
|
pin := string(input)
|
|
|
|
|
|
|
|
|
|
|
@ -392,22 +394,22 @@ func (h *Handlers) Unlock(ctx context.Context, sym string, input []byte) (resour
|
|
|
|
if len(input) == 4 {
|
|
|
|
if len(input) == 4 {
|
|
|
|
if pin != accountData["AccountPIN"] {
|
|
|
|
if pin != accountData["AccountPIN"] {
|
|
|
|
res.FlagSet = append(res.FlagSet, models.USERFLAG_INCORRECTPIN)
|
|
|
|
res.FlagSet = append(res.FlagSet, models.USERFLAG_INCORRECTPIN)
|
|
|
|
res.FlagReset = append(res.FlagReset, models.USERFLAG_ACCOUNT_UNLOCKED)
|
|
|
|
res.FlagReset = append(res.FlagReset, models.USERFLAG_ACCOUNT_AUTHORIZED)
|
|
|
|
return res, nil
|
|
|
|
return res, nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if h.fs.St.MatchFlag(models.USERFLAG_ACCOUNT_UNLOCKED, false) {
|
|
|
|
if h.fs.St.MatchFlag(models.USERFLAG_ACCOUNT_AUTHORIZED, false) {
|
|
|
|
res.FlagReset = append(res.FlagReset, models.USERFLAG_INCORRECTPIN)
|
|
|
|
res.FlagReset = append(res.FlagReset, models.USERFLAG_INCORRECTPIN)
|
|
|
|
res.FlagSet = append(res.FlagSet, models.USERFLAG_UNLOCKFORUPDATE)
|
|
|
|
res.FlagSet = append(res.FlagSet, models.USERFLAG_ALLOW_UPDATE)
|
|
|
|
res.FlagSet = append(res.FlagSet, models.USERFLAG_ACCOUNT_UNLOCKED)
|
|
|
|
res.FlagSet = append(res.FlagSet, models.USERFLAG_ACCOUNT_AUTHORIZED)
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
res.FlagSet = append(res.FlagSet, models.USERFLAG_UNLOCKFORUPDATE)
|
|
|
|
res.FlagSet = append(res.FlagSet, models.USERFLAG_ALLOW_UPDATE)
|
|
|
|
res.FlagReset = append(res.FlagReset, models.USERFLAG_ACCOUNT_UNLOCKED)
|
|
|
|
res.FlagReset = append(res.FlagReset, models.USERFLAG_ACCOUNT_AUTHORIZED)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return res, nil
|
|
|
|
return res, nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//ResetIncorrectPin resets the incorrect pin flag after a new PIN attempt.
|
|
|
|
// ResetIncorrectPin resets the incorrect pin flag after a new PIN attempt.
|
|
|
|
func (h *Handlers) ResetIncorrectPin(ctx context.Context, sym string, input []byte) (resource.Result, error) {
|
|
|
|
func (h *Handlers) ResetIncorrectPin(ctx context.Context, sym string, input []byte) (resource.Result, error) {
|
|
|
|
res := resource.Result{}
|
|
|
|
res := resource.Result{}
|
|
|
|
res.FlagReset = append(res.FlagReset, models.USERFLAG_INCORRECTPIN)
|
|
|
|
res.FlagReset = append(res.FlagReset, models.USERFLAG_INCORRECTPIN)
|
|
|
@ -458,7 +460,7 @@ func (h *Handlers) Quit(ctx context.Context, sym string, input []byte) (resource
|
|
|
|
l.AddDomain("default")
|
|
|
|
l.AddDomain("default")
|
|
|
|
|
|
|
|
|
|
|
|
res.Content = l.Get("Thank you for using Sarafu. Goodbye!")
|
|
|
|
res.Content = l.Get("Thank you for using Sarafu. Goodbye!")
|
|
|
|
res.FlagReset = append(res.FlagReset, models.USERFLAG_ACCOUNT_UNLOCKED)
|
|
|
|
res.FlagReset = append(res.FlagReset, models.USERFLAG_ACCOUNT_AUTHORIZED)
|
|
|
|
return res, nil
|
|
|
|
return res, nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -482,7 +484,7 @@ func (h *Handlers) VerifyYob(ctx context.Context, sym string, input []byte) (res
|
|
|
|
return res, nil
|
|
|
|
return res, nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//ResetIncorrectYob resets the incorrect date format after a new attempt
|
|
|
|
// ResetIncorrectYob resets the incorrect date format after a new attempt
|
|
|
|
func (h *Handlers) ResetIncorrectYob(ctx context.Context, sym string, input []byte) (resource.Result, error) {
|
|
|
|
func (h *Handlers) ResetIncorrectYob(ctx context.Context, sym string, input []byte) (resource.Result, error) {
|
|
|
|
res := resource.Result{}
|
|
|
|
res := resource.Result{}
|
|
|
|
res.FlagReset = append(res.FlagReset, models.USERFLAG_INCORRECTDATEFORMAT)
|
|
|
|
res.FlagReset = append(res.FlagReset, models.USERFLAG_INCORRECTDATEFORMAT)
|
|
|
@ -737,7 +739,6 @@ func (h *Handlers) GetAmount(ctx context.Context, sym string, input []byte) (res
|
|
|
|
return res, nil
|
|
|
|
return res, nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// QuickWithBalance retrieves the balance for a given public key from the custodial balance API endpoint before
|
|
|
|
// QuickWithBalance retrieves the balance for a given public key from the custodial balance API endpoint before
|
|
|
|
// gracefully exiting the session.
|
|
|
|
// gracefully exiting the session.
|
|
|
|
func (h *Handlers) QuitWithBalance(ctx context.Context, sym string, input []byte) (resource.Result, error) {
|
|
|
|
func (h *Handlers) QuitWithBalance(ctx context.Context, sym string, input []byte) (resource.Result, error) {
|
|
|
@ -754,7 +755,7 @@ func (h *Handlers) QuitWithBalance(ctx context.Context, sym string, input []byte
|
|
|
|
return res, nil
|
|
|
|
return res, nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|
res.Content = l.Get("Your account balance is %s", balance)
|
|
|
|
res.Content = l.Get("Your account balance is %s", balance)
|
|
|
|
res.FlagReset = append(res.FlagReset, models.USERFLAG_ACCOUNT_UNLOCKED)
|
|
|
|
res.FlagReset = append(res.FlagReset, models.USERFLAG_ACCOUNT_AUTHORIZED)
|
|
|
|
return res, nil
|
|
|
|
return res, nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -785,6 +786,6 @@ func (h *Handlers) InitiateTransaction(ctx context.Context, sym string, input []
|
|
|
|
return res, err
|
|
|
|
return res, err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
res.FlagReset = append(res.FlagReset, models.USERFLAG_ACCOUNT_UNLOCKED)
|
|
|
|
res.FlagReset = append(res.FlagReset, models.USERFLAG_ACCOUNT_AUTHORIZED)
|
|
|
|
return res, nil
|
|
|
|
return res, nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|