Skip to content

Commit

Permalink
Added dialog for change email.
Browse files Browse the repository at this point in the history
  • Loading branch information
jigar-f committed Jan 10, 2024
1 parent 3e58eee commit a999e0c
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 8 deletions.
8 changes: 8 additions & 0 deletions assets/locales/en.po
Original file line number Diff line number Diff line change
Expand Up @@ -1609,6 +1609,14 @@ msgstr "This device has been Linked to %s"
msgid "new_to_lantern"
msgstr "New to Lantern? "

msgid "email_has_been_updated"
msgstr "Email has been updated"


msgid "email_has_been_updated_message"
msgstr "Your Email has been changed successfully"





Expand Down
8 changes: 3 additions & 5 deletions internalsdk/session_model.go
Original file line number Diff line number Diff line change
Expand Up @@ -1209,7 +1209,6 @@ func login(session *SessionModel, email string, password string) error {
Email: email,
A: A.Bytes(),
}
log.Debugf("A Bytes %v", A.Bytes())
srpB, err := apimodels.LoginPrepare(prepareRequestBody)
if err != nil {
return err
Expand Down Expand Up @@ -1272,15 +1271,16 @@ func login(session *SessionModel, email string, password string) error {
if err != nil {
log.Errorf("Error while saving user salt %v", err)
}
end := time.Now()
log.Debugf("Login took %v", end.Sub(start))

//Store all the user details
userData := ConvertToUserDetailsResponse(login)
err = cacheUserDetail(session.baseModel, &userData)
if err != nil {
log.Errorf("Error while caching user details %v", err)
return err
}
end := time.Now()
log.Debugf("Login took %v", end.Sub(start))
return nil
}

Expand Down Expand Up @@ -1347,13 +1347,11 @@ func changeEmail(session SessionModel, email string, newEmail string, password s
Email: email,
A: A.Bytes(),
}
log.Debugf("A Bytes %v", A.Bytes())
srpB, err := apimodels.LoginPrepare(prepareRequestBody)
if err != nil {
return err
}
log.Debugf("Login prepare response %v", srpB)

// // Once the client receives B from the server Client should check error status here as defense against
// // a malicious B sent from server
B := big.NewInt(0).SetBytes(srpB.B)
Expand Down
15 changes: 12 additions & 3 deletions lib/account/auth/change_email.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// ignore_for_file: use_build_context_synchronously

import 'package:email_validator/email_validator.dart';

import '../../common/common.dart';
Expand All @@ -20,7 +22,7 @@ class _ChangeEmailState extends State<ChangeEmail> {
late final _emailController = CustomTextEditingController(
formKey: _emailFormKey,
validator: (value) => EmailValidator.validate(value ?? '')
? null
? null
: 'please_enter_a_valid_email_address'.i18n,
);

Expand Down Expand Up @@ -135,8 +137,15 @@ class _ChangeEmailState extends State<ChangeEmail> {
await sessionModel.changeEmail(
widget.email, _emailController.text, _passwordController.text);
context.loaderOverlay.hide();
//Once email changed, pop
context.router.pop();
CDialog.successDialog(
context: context,
title: 'email_has_been_updated'.i18n,
description: 'email_has_been_updated_message'.i18n,
successCallback: () {
//Once email changed, pop
context.router.pop();
},
);
} catch (e) {
context.loaderOverlay.hide();
CDialog.showError(context, description: e.localizedDescription);
Expand Down

0 comments on commit a999e0c

Please sign in to comment.