diff --git a/handlers/application/menuhandler.go b/handlers/application/menuhandler.go index d25cad0..d6d56a2 100644 --- a/handlers/application/menuhandler.go +++ b/handlers/application/menuhandler.go @@ -8,6 +8,7 @@ import ( "path" "strconv" "strings" + "unicode" "gopkg.in/leonelquinteros/gotext.v1" @@ -1143,7 +1144,12 @@ func (h *MenuHandlers) GetCurrentProfileInfo(ctx context.Context, sym string, in logg.ErrorCtxf(ctx, "Failed to read account alias entry with", "key", "error", storedb.DATA_ACCOUNT_ALIAS, err) return res, err } - res.Content = string(profileInfo) + alias := string(profileInfo) + if alias == "" { + res.Content = defaultValue + } else { + res.Content = alias + } default: break } @@ -1187,8 +1193,10 @@ func (h *MenuHandlers) GetProfileInfo(ctx context.Context, sym string, input []b offerings := getEntryOrDefault(store.ReadEntry(ctx, sessionId, storedb.DATA_OFFERINGS)) alias := getEntryOrDefault(store.ReadEntry(ctx, sessionId, storedb.DATA_ACCOUNT_ALIAS)) - if alias != defaultValue { + if alias != defaultValue && alias != "" { alias = strings.Split(alias, ".")[0] + } else { + alias = defaultValue } // Construct the full name @@ -1269,20 +1277,10 @@ func (h *MenuHandlers) UpdateAllProfileItems(ctx context.Context, sym string, in if !ok { return res, fmt.Errorf("missing session") } - flag_alias_set, _ := h.flagManager.GetFlag("flag_alias_set") - aliasSet := h.st.MatchFlag(flag_alias_set, true) - err := h.insertProfileItems(ctx, sessionId, &res) if err != nil { return res, err } - //Only request an alias if it has not been set yet: - if !aliasSet { - err = h.constructAccountAlias(ctx) - if err != nil { - return res, err - } - } return res, nil } @@ -2534,7 +2532,8 @@ func (h *MenuHandlers) RequestCustomAlias(ctx context.Context, sym string, input return res, nil } } - aliasResult, err := h.accountService.RequestAlias(ctx, string(pubKey), string(input)) + sanitizedInput := sanitizeAliasHint(string(input)) + aliasResult, err := h.accountService.RequestAlias(ctx, string(pubKey), sanitizedInput) if err != nil { logg.ErrorCtxf(ctx, "failed to retrieve alias", "alias", string(aliasHint), "error_alias_request", err) return res, fmt.Errorf("Failed to retrieve alias: %s", err.Error()) @@ -2551,6 +2550,17 @@ func (h *MenuHandlers) RequestCustomAlias(ctx context.Context, sym string, input return res, nil } +func sanitizeAliasHint(input string) string { + for i, r := range input { + // Check if the character is a special character (non-alphanumeric) + if !unicode.IsLetter(r) && !unicode.IsNumber(r) { + return input[:i] + } + } + // If no special character is found, return the whole input + return input +} + // GetSuggestedAlias loads and displays the suggested alias name from the temporary value func (h *MenuHandlers) GetSuggestedAlias(ctx context.Context, sym string, input []byte) (resource.Result, error) { var res resource.Result diff --git a/services/registration/locale/swa/default.po b/services/registration/locale/swa/default.po index 6155063..cac4737 100644 --- a/services/registration/locale/swa/default.po +++ b/services/registration/locale/swa/default.po @@ -30,3 +30,7 @@ msgstr "Salio la Kikundi: 0.00" msgid "Symbol: %s\nBalance: %s" msgstr "Sarafu: %s\nSalio: %s" + + +msgid "%s balance: %s\n" +msgstr "%s salio: %s\n" \ No newline at end of file diff --git a/services/registration/my_account_alias b/services/registration/my_account_alias index 678037b..726f06b 100644 --- a/services/registration/my_account_alias +++ b/services/registration/my_account_alias @@ -1,2 +1,2 @@ Current alias: {{.get_current_profile_info}} -Edit my alias: \ No newline at end of file +Enter your preferred alias:: \ No newline at end of file diff --git a/services/registration/my_account_alias_swa b/services/registration/my_account_alias_swa index 6d88e89..0ea3166 100644 --- a/services/registration/my_account_alias_swa +++ b/services/registration/my_account_alias_swa @@ -1,2 +1,2 @@ Lakabu ya sasa: {{.get_current_profile_info}} -Badilisha Lakabu yangu: \ No newline at end of file +Weka lakabu unalopendelea:: \ No newline at end of file