Compare commits

..

No commits in common. "a38ac06a3d7bcfc69d96e0c406a755d84fe9f333" and "0274133d4892e5b766bc5767c89f7b5aad6f4647" have entirely different histories.

3 changed files with 15 additions and 21 deletions

View File

@ -1222,8 +1222,7 @@ func (h *MenuHandlers) ResetAccountAuthorized(ctx context.Context, sym string, i
return res, nil
}
// CheckIdentifier retrieves the Public key from the userdatastore under the key: DATA_PUBLIC_KEY and triggers an sms that
// will be sent to the associated session id
// CheckIdentifier retrieves the PublicKey from the JSON data file.
func (h *MenuHandlers) CheckIdentifier(ctx context.Context, sym string, input []byte) (resource.Result, error) {
var res resource.Result
sessionId, ok := ctx.Value("SessionId").(string)
@ -1231,18 +1230,9 @@ func (h *MenuHandlers) CheckIdentifier(ctx context.Context, sym string, input []
return res, fmt.Errorf("missing session")
}
store := h.userdataStore
publicKey, err := store.ReadEntry(ctx, sessionId, storedb.DATA_PUBLIC_KEY)
if err != nil {
logg.ErrorCtxf(ctx, "failed to read publicKey entry with", "key", storedb.DATA_PUBLIC_KEY, "error", err)
return res, err
}
publicKey, _ := store.ReadEntry(ctx, sessionId, storedb.DATA_PUBLIC_KEY)
res.Content = string(publicKey)
//trigger an address sms to be delivered to the associated session id
err = h.sendAddressSMS(ctx)
if err != nil {
logg.DebugCtxf(ctx, "Failed to trigger an address sms", "error", err)
return res, nil
}
return res, nil
}
@ -2511,35 +2501,36 @@ func (h *MenuHandlers) ClearTemporaryValue(ctx context.Context, sym string, inpu
}
// SendAddressSMS will triger an SMS when a user navigates to the my address node.The SMS will be sent to the associated phonenumber.
func (h *MenuHandlers) sendAddressSMS(ctx context.Context) error {
func (h *MenuHandlers) SendAddressSMS(ctx context.Context, sym string, input []byte) (resource.Result, error) {
var res resource.Result
store := h.userdataStore
sessionId, ok := ctx.Value("SessionId").(string)
if !ok {
return fmt.Errorf("missing session")
return res, fmt.Errorf("missing session")
}
publicKey, err := store.ReadEntry(ctx, sessionId, storedb.DATA_PUBLIC_KEY)
if err != nil {
logg.ErrorCtxf(ctx, "failed to read publicKey entry with", "key", storedb.DATA_PUBLIC_KEY, "error", err)
return err
return res, err
}
originPhone, err := phone.FormatPhoneNumber(sessionId)
if err != nil {
logg.DebugCtxf(ctx, "Failed to format origin phonenumber", "sessionid", sessionId)
return nil
return res, nil
}
if !phone.IsValidPhoneNumber(originPhone) {
logg.InfoCtxf(ctx, "Invalid origin phone number", "origin phonenumber", originPhone)
return fmt.Errorf("invalid origin phone number")
logg.InfoCtxf(ctx, "Invalid origin phone number", "sessionid:", sessionId)
return res, nil
}
err = h.accountService.SendAddressSMS(ctx, string(publicKey), sessionId)
if err != nil {
logg.DebugCtxf(ctx, "Failed to send address sms", "error", err)
return fmt.Errorf("Failed to send address sms: %v", err)
return res, nil
}
return nil
return res, nil
}
// sendPINResetSMS will send an SMS to a user's phonenumber in the event that the associated account's PIN has been reset.

View File

@ -124,6 +124,7 @@ func (ls *LocalHandlerService) GetHandler(accountService remote.AccountService)
ls.DbRs.AddLocalFunc("get_suggested_alias", appHandlers.GetSuggestedAlias)
ls.DbRs.AddLocalFunc("confirm_new_alias", appHandlers.ConfirmNewAlias)
ls.DbRs.AddLocalFunc("check_account_created", appHandlers.CheckAccountCreated)
ls.DbRs.AddLocalFunc("send_address_sms", appHandlers.SendAddressSMS)
ls.first = appHandlers.Init

View File

@ -1,4 +1,6 @@
LOAD send_address_sms 16
LOAD check_identifier 0
RELOAD check_identifier
MAP check_identifier
MOUT back 0
MOUT quit 9