Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[My Site Migration] mobile verification page (Part - 2) #1004

Open
wants to merge 7 commits into
base: develop
Choose a base branch
from

Conversation

MayankBansal12
Copy link
Contributor

@MayankBansal12 MayankBansal12 commented Feb 14, 2025

Date: 15-02-2025

Developer Name: @MayankBansal12


Issue Ticket Number:-

Description:

  • Mobile verification page is being moved from my-site to main-site at /mobile route.
    This is the second PR following [My Site Migration] mobile verification page (Part - 1) #1003 which moves the mobile route
  • This PR moves the mobile controller and contains its unit tests
  • QR Auth Component and integration tests for the same

Is Under Feature Flag

  • Yes
  • No

Database changes

  • Yes
  • No

Breaking changes (If your feature is breaking/missing something please mention pending tickets)

  • Yes
  • No

Is Development Tested?

  • Yes
  • No

Tested in staging?

  • Yes
  • No

Add relevant Screenshot below ( e.g test coverage etc. )

Note:- Working video doesn't show complete flow due to QR code scan behaviour not being mocked using mobile app

Working video
Screencast.from.2025-02-19.20-27-01.mp4
tests

controller test
component test
test run

Copy link
Member

@tejaskh3 tejaskh3 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you please tell me, where are the test cases for template and route file?

@MayankBansal12
Copy link
Contributor Author

MayankBansal12 commented Feb 17, 2025

could you please tell me, where are the test cases for template and route file?

this PR contains mobile controller only.
route and its test cases are in PR #1003
and further template code and components to be followed in the next PR.

@MayankBansal12 MayankBansal12 force-pushed the migrate/mobile-verification-2 branch from 9704b18 to c27bd15 Compare February 19, 2025 15:25
Copy link
Contributor

@Suvidh-kaushik Suvidh-kaushik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.!

iamitprakash
iamitprakash previously approved these changes Feb 22, 2025
@iamitprakash iamitprakash self-requested a review February 22, 2025 18:11
}

@action async verifyAuth() {
if (confirm(QR_SCAN_CONFIRMATION_MESSAGE)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is confirm here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

confirm here opens up a modal to verify user has scanned QR code and wants to authorise the device
eg:
image

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So why not a proper modal? that matches the design with other things?

Comment on lines 34 to 47
async handleAuthStatus(status, successMessage) {
try {
const response = await this.fetchAuthStatus(status);
if (!response || response.status !== 200) {
throw new Error(ERROR_MESSAGES.somethingWentWrong);
}
this.toast.success(successMessage, 'Success');
if (status === AUTH_STATUS.AUTHORIZED) {
this.router.transitionTo('/');
}
} catch (error) {
this.toast.error(ERROR_MESSAGES.somethingWentWrong, '', TOAST_OPTIONS);
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is going on here? what is it taking as input what is it doing?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated the func naming and structure, it should be clear now.

Comment on lines 60 to 76
@action async verifyBtnClicked() {
try {
const response = await fetch(FETCH_DEVICE_INFO, {
method: 'GET',
headers: {
'Content-Type': 'application/json',
},
credentials: 'include',
});
if (response.status === 200) {
await this.verifyAuth();
} else this.toast.error(QR_SCAN_MESSAGE, 'Not verified', TOAST_OPTIONS);
} catch (error) {
this.toast.error('error');
}
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure, what is going on here.
Not able to figure out what this function does through the function name

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated the function name

<QrAuth @qrCodeText={{@model}} @verifyStatus={{this.verifyBtnClicked}} />
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

verifyStatus of what?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated the naming

@@ -0,0 +1,73 @@
import Controller from '@ember/controller';
import { action } from '@ember/object';
import { inject as service } from '@ember/service';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
import { inject as service } from '@ember/service';
import { service } from '@ember/service';

await this.confirmQRAuth();
} else this.toast.error(QR_SCAN_MESSAGE, 'Not verified', TOAST_OPTIONS);
} catch (error) {
this.toast.error('error');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What error? no message?

});
if (response.status === 200) {
await this.confirmQRAuth();
} else this.toast.error(QR_SCAN_MESSAGE, 'Not verified', TOAST_OPTIONS);
Copy link
Contributor

@prakashchoudhary07 prakashchoudhary07 Feb 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
} else this.toast.error(QR_SCAN_MESSAGE, 'Not verified', TOAST_OPTIONS);
} else {
this.toast.error(QR_SCAN_MESSAGE, 'Not verified', TOAST_OPTIONS);
}

Easier to read

Comment on lines +24 to +30
const response = await fetch(`${QR_AUTHORIZATION_STATUS_URL}/${status}`, {
method: 'PATCH',
headers: {
'Content-Type': 'application/json',
},
credentials: 'include',
});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NIT: Please create a util function for fetching, where we just pass the method, body and headers if required

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[My Site Migration] Create a mobile verification page
5 participants