Skip to content

Commit ccc53f5

Browse files
Merge pull request #1338 from Ekep-Obasi/feat/update-redirects-on-login-and-logout-actions
update redirects on login and logout actions
2 parents ff928e5 + c7af1bf commit ccc53f5

File tree

6 files changed

+88
-4
lines changed

6 files changed

+88
-4
lines changed

cypress/e2e/34_signoutPostBounty.cy.ts

+3
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ describe('Signed Out Post Bounty Flow ', () => {
2323
cy.haves_phinx_login(activeUser);
2424
cy.wait(1000);
2525

26+
cy.visit('http://localhost:3007/bounties');
27+
cy.wait(1000);
28+
2629
cy.create_bounty(bounty);
2730
cy.wait(1000);
2831

cypress/e2e/63_auth_redirects.cy.ts

+80
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
describe('Authentication Redirects', () => {
2+
beforeEach(() => {
3+
cy.clearCookies();
4+
cy.clearLocalStorage();
5+
});
6+
7+
it('should redirect to profile page after login', () => {
8+
cy.visit('http://localhost:3007');
9+
cy.wait(3000);
10+
11+
cy.contains('Sign in').click();
12+
13+
let user;
14+
let challenge;
15+
let token;
16+
let info;
17+
18+
cy.fixture('nodes.json').then((json) => {
19+
user = json[0];
20+
const userAlias = user.alias;
21+
22+
cy.get('[data-challenge]')
23+
.invoke('attr', 'data-challenge')
24+
.then((value) => {
25+
const array = value?.split('&');
26+
if (array && array.length === 4) {
27+
challenge = array[2].substring(10);
28+
}
29+
});
30+
31+
cy.request({
32+
method: 'POST',
33+
url: `${user.external_ip}/verify_external`,
34+
headers: {
35+
'x-user-token': `${user.authToken}`
36+
}
37+
}).then((response) => {
38+
({ token } = response.body.response);
39+
({ info } = response.body.response);
40+
});
41+
42+
cy.request({
43+
method: 'GET',
44+
url: `${user.external_ip}/signer/U98BoaW54IFZlcmlmaWNhdGlvbg==`,
45+
headers: {
46+
'x-user-token': `${user.authToken}`
47+
}
48+
}).then((response) => {
49+
info.url = `${user.external_ip}`;
50+
info['verification_signature'] = response.body.response.sig;
51+
52+
cy.request({
53+
method: 'POST',
54+
url: `http://localhost:13000/verify/${challenge}?token=${token}`,
55+
body: info
56+
});
57+
58+
cy.url().should('include', '/p/').and('include', '/workspaces');
59+
cy.contains(userAlias).should('exist');
60+
});
61+
});
62+
});
63+
64+
it('should redirect to homepage after logout', () => {
65+
cy.fixture('nodes.json').then((json) => {
66+
const user = json[0];
67+
cy.login(user.alias);
68+
69+
cy.visit(`http://localhost:3007/p/${user.pubkey}/workspaces`);
70+
71+
cy.contains(user.alias).click();
72+
73+
cy.contains('Sign out').click();
74+
75+
cy.url().should('eq', 'http://localhost:3007/');
76+
77+
cy.contains('Sign in').should('be.visible');
78+
});
79+
});
80+
});

cypress/support/commands.ts

+2
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,8 @@ Cypress.Commands.add('login', (userAlias: string) => {
9797
});
9898

9999
cy.contains(userAlias).eq(0);
100+
101+
cy.visit('http://localhost:3007/bounties');
100102
});
101103
});
102104

src/components/BountyComponents/BountyNavBar.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -462,7 +462,7 @@ const BountyNavBar: React.FC = () => {
462462
onSuccess={() => {
463463
ui.setShowSignIn(false);
464464
setShowWelcome(true);
465-
window.location.reload();
465+
goToEditSelf();
466466
}}
467467
/>
468468
</StyledModal>

src/people/main/Header.tsx

+1-2
Original file line numberDiff line numberDiff line change
@@ -613,8 +613,7 @@ function Header() {
613613
onSuccess={() => {
614614
ui.setShowSignIn(false);
615615
setShowWelcome(true);
616-
// if page is not /p, go to /p (people)
617-
window.location.reload();
616+
goToEditSelf();
618617
}}
619618
/>
620619
</Modal>

src/people/userInfo/hooks.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export const useUserInfo = () => {
3737
ui.setMeInfo(null);
3838
main.getPeople({ resetPage: true });
3939
main.setLnToken('');
40-
goBack();
40+
history.push('/');
4141
}
4242

4343
const onEdit = () => {

0 commit comments

Comments
 (0)