Skip to content

Commit

Permalink
Merge pull request #2516 from alphagov/revert-credentials-update
Browse files Browse the repository at this point in the history
Revert "PP-7583 Update credentials routes"
  • Loading branch information
stephencdaly authored Jan 20, 2021
2 parents b1eb000 + 506b145 commit 82a630a
Show file tree
Hide file tree
Showing 14 changed files with 834 additions and 48 deletions.
4 changes: 2 additions & 2 deletions .secrets.baseline
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"files": "package-lock.json",
"lines": null
},
"generated_at": "2021-01-19T17:38:25Z",
"generated_at": "2021-01-19T16:07:47Z",
"plugins_used": [
{
"name": "AWSKeyDetector"
Expand Down Expand Up @@ -72,7 +72,7 @@
"hashed_secret": "ece65afda87c1c6120602c9a3b66890308d7e53c",
"is_secret": false,
"is_verified": false,
"line_number": 138,
"line_number": 127,
"type": "Secret Keyword"
}
],
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/credentials.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ module.exports = {

if (_.get(req, 'session.flash.genericError.length')) {
_.set(req, 'session.pageData.editNotificationCredentials', { username, password })
return res.redirect(formatAccountPathsFor(paths.account.notificationCredentials.edit, req.account && req.account.external_id))
return res.redirect(paths.notificationCredentials.edit)
}

const correlationId = req.headers[CORRELATION_HEADER] || ''
Expand Down
37 changes: 19 additions & 18 deletions app/paths.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,6 @@ module.exports = {
revoke: '/api-keys/revoke',
update: '/api-keys/update'
},
credentials: {
index: '/credentials',
edit: '/credentials/edit'
},
digitalWallet: {
applePay: '/digital-wallet/apple-pay',
googlePay: '/digital-wallet/google-pay'
Expand All @@ -39,10 +35,6 @@ module.exports = {
confirmation: '/email-settings-confirmation',
refund: '/email-settings-refund'
},
notificationCredentials: {
edit: '/notification-credentials/edit',
update: '/notification-credentials'
},
paymentLinks: {
start: '/create-payment-link',
information: '/create-payment-link/information',
Expand Down Expand Up @@ -87,15 +79,6 @@ module.exports = {
},
settings: {
index: '/settings'
},
stripe: {
addPspAccountDetails: '/stripe/add-psp-account-details'
},
stripeSetup: {
bankDetails: '/bank-details',
responsiblePerson: '/responsible-person',
vatNumber: '/vat-number',
companyNumber: '/company-number'
},
toggle3ds: {
index: '/3ds'
Expand All @@ -111,6 +94,15 @@ module.exports = {
index: '/your-psp',
flex: '/your-psp/flex',
worldpay3dsFlex: '/your-psp/worldpay-3ds-flex'
},
stripeSetup: {
bankDetails: '/bank-details',
responsiblePerson: '/responsible-person',
vatNumber: '/vat-number',
companyNumber: '/company-number'
},
stripe: {
addPspAccountDetails: '/stripe/add-psp-account-details'
}
},
redirects: {
Expand All @@ -127,7 +119,16 @@ module.exports = {
index: '/all-service-transactions',
download: '/all-service-transactions/download'
},

credentials: {
index: '/credentials',
edit: '/credentials/edit',
create: '/credentials'
},
notificationCredentials: {
index: '/credentials',
edit: '/notification-credentials/edit',
update: '/notification-credentials'
},
user: {
logIn: '/login',
otpLogIn: '/otp-login',
Expand Down
24 changes: 17 additions & 7 deletions app/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,27 +86,26 @@ const stripeSetupDashboardRedirectController = require('./controllers/stripe-set

// Assignments
const {
healthcheck, registerUser, user, dashboard, selfCreateService, transactions,
serviceSwitcher,teamMembers, staticPaths, inviteValidation, editServiceName, merchantDetails,
healthcheck, registerUser, user, dashboard, selfCreateService, transactions, credentials,
serviceSwitcher, teamMembers, staticPaths, inviteValidation, editServiceName, merchantDetails,
notificationCredentials,
requestToGoLive, policyPages,
allServiceTransactions, payouts, redirects
} = paths
const {
apiKeys,
credentials,
digitalWallet,
emailNotifications,
notificationCredentials,
paymentLinks,
paymentTypes,
prototyping,
settings,
stripe,
stripeSetup,
toggle3ds,
toggleBillingAddress,
toggleMotoMaskCardNumberAndSecurityCode,
yourPsp
yourPsp,
stripeSetup,
stripe
} = paths.account

// Exports
Expand Down Expand Up @@ -184,10 +183,13 @@ module.exports.bind = function (app) {
const authenticatedPaths = [
...lodash.values(transactions),
...lodash.values(allServiceTransactions),
...lodash.values(credentials),
...lodash.values(notificationCredentials),
...lodash.values(editServiceName),
...lodash.values(serviceSwitcher),
...lodash.values(teamMembers),
...lodash.values(merchantDetails),
...lodash.values(paymentLinks),
...lodash.values(user.profile),
...lodash.values(requestToGoLive),
...lodash.values(policyPages),
Expand Down Expand Up @@ -289,9 +291,17 @@ module.exports.bind = function (app) {
account.post(yourPsp.flex, permission('gateway-credentials:update'), paymentMethodIsCard, yourPspController.postFlex)

// Credentials
app.get(credentials.index, permission('gateway-credentials:read'), getAccount, paymentMethodIsCard, credentialsController.index)
app.get(credentials.edit, permission('gateway-credentials:update'), getAccount, paymentMethodIsCard, credentialsController.editCredentials)
app.post(credentials.index, permission('gateway-credentials:update'), getAccount, paymentMethodIsCard, credentialsController.update)
app.get(notificationCredentials.index, permission('gateway-credentials:read'), getAccount, paymentMethodIsCard, credentialsController.index)
app.get(notificationCredentials.edit, permission('gateway-credentials:update'), getAccount, paymentMethodIsCard, credentialsController.editNotificationCredentials)
app.post(notificationCredentials.update, permission('gateway-credentials:update'), getAccount, paymentMethodIsCard, credentialsController.updateNotificationCredentials)

account.get(credentials.index, permission('gateway-credentials:read'), paymentMethodIsCard, credentialsController.index)
account.get(credentials.edit, permission('gateway-credentials:update'), paymentMethodIsCard, credentialsController.editCredentials)
account.post(credentials.index, permission('gateway-credentials:update'), paymentMethodIsCard, credentialsController.update)
account.get(notificationCredentials.index, permission('gateway-credentials:read'), paymentMethodIsCard, credentialsController.index)
account.get(notificationCredentials.edit, permission('gateway-credentials:update'), paymentMethodIsCard, credentialsController.editNotificationCredentials)
account.post(notificationCredentials.update, permission('gateway-credentials:update'), paymentMethodIsCard, credentialsController.updateNotificationCredentials)

Expand Down
4 changes: 2 additions & 2 deletions app/utils/nav-builder.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ const mainSettingsPaths = [

const yourPspPaths = [
paths.account.yourPsp,
paths.account.credentials,
paths.account.notificationCredentials
paths.credentials,
paths.notificationCredentials
]

const serviceNavigationItems = (currentPath, permissions, type, account = {}) => {
Expand Down
2 changes: 1 addition & 1 deletion app/views/credentials/epdq.njk
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
{% block provider_content %}

{% if permissions.gateway_credentials_update %}
<form id="credentials-form" method="post" action="{{ formatAccountPathsFor(routes.account.credentials.index, currentGatewayAccount.external_id) }}" data-validate>
<form id="credentials-form" method="post" action="{{routes.credentials.create}}" data-validate>
<input id="csrf" name="csrfToken" type="hidden" value="{{csrf}}" />

{{ govukInput({
Expand Down
4 changes: 2 additions & 2 deletions app/views/credentials/smartpay.njk
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

{% block provider_content %}
{% if editNotificationCredentialsMode %}
<form id="notification_credentials_form" method="post" action="{{ formatAccountPathsFor(routes.account.notificationCredentials.update, currentGatewayAccount.external_id) }}" data-validate>
<form id="notification_credentials_form" method="post" action="{{routes.notificationCredentials.update}}" data-validate>
<input id="notification-csrf" name="csrfToken" type="hidden" value="{{csrf}}" />

{% set username %}{{lastNotificationsData.username or currentGatewayAccount.notificationCredentials.userName}}{% endset %}
Expand Down Expand Up @@ -47,7 +47,7 @@
</form>
{% else %}
{% if permissions.gateway_credentials_update %}
<form id="credentials-form" method="post" action="{{ formatAccountPathsFor(routes.account.credentials.index, currentGatewayAccount.external_id) }}" data-validate>
<form id="credentials-form" method="post" action="{{routes.credentials.create}}" data-validate>
<input id="csrf" name="csrfToken" type="hidden" value="{{csrf}}" />

{{ govukInput({
Expand Down
2 changes: 1 addition & 1 deletion app/views/credentials/worldpay.njk
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

{% block provider_content %}
{% if permissions.gateway_credentials_update %}
<form id="credentials-form" method="post" action="{{ formatAccountPathsFor(routes.account.credentials.index, currentGatewayAccount.external_id) }}" data-validate>
<form id="credentials-form" method="post" action="{{routes.credentials.create}}" data-validate>
<input id="csrf" name="csrfToken" type="hidden" value="{{csrf}}" />

{% if change === 'merchantId' %}
Expand Down
10 changes: 5 additions & 5 deletions app/views/your-psp/_epdq.njk
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
actions: {
items: [
{
href: formatAccountPathsFor(routes.account.credentials.edit, currentGatewayAccount.external_id) + "?change=merchantId",
href: routes.credentials.edit + "?change=merchantId",
text: "Change",
visuallyHiddenText: "account credentials",
attributes: {
Expand All @@ -39,7 +39,7 @@
actions: {
items: [
{
href: formatAccountPathsFor(routes.account.credentials.edit, currentGatewayAccount.external_id) + "?change=username",
href: routes.credentials.edit + "?change=username",
text: "Change",
visuallyHiddenText: "account credentials"
}
Expand All @@ -57,7 +57,7 @@
actions: {
items: [
{
href: formatAccountPathsFor(routes.account.credentials.edit, currentGatewayAccount.external_id) + "?change=password",
href: routes.credentials.edit + "?change=password",
text: "Change",
visuallyHiddenText: "account credentials"
}
Expand All @@ -75,7 +75,7 @@
actions: {
items: [
{
href: formatAccountPathsFor(routes.account.credentials.edit, currentGatewayAccount.external_id) + "?change=password",
href: routes.credentials.edit + "?change=password",
text: "Change",
visuallyHiddenText: "account credentials"
}
Expand All @@ -93,7 +93,7 @@
actions: {
items: [
{
href: formatAccountPathsFor(routes.account.credentials.edit, currentGatewayAccount.external_id) + "?change=password",
href: routes.credentials.edit + "?change=password",
text: "Change",
visuallyHiddenText: "account credentials"
}
Expand Down
10 changes: 5 additions & 5 deletions app/views/your-psp/_smartpay.njk
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
actions: {
items: [
{
href: formatAccountPathsFor(routes.account.credentials.edit, currentGatewayAccount.external_id) + "?change=merchantId",
href: routes.credentials.edit + "?change=merchantId",
text: "Change",
visuallyHiddenText: "account credentials",
attributes: {
Expand All @@ -38,7 +38,7 @@
actions: {
items: [
{
href: formatAccountPathsFor(routes.account.credentials.edit, currentGatewayAccount.external_id) + "?change=username",
href: routes.credentials.edit + "?change=username",
text: "Change",
visuallyHiddenText: "account credentials"
}
Expand All @@ -56,7 +56,7 @@
actions: {
items: [
{
href: formatAccountPathsFor(routes.account.credentials.edit, currentGatewayAccount.external_id) + "?change=password",
href: routes.credentials.edit + "?change=password",
text: "Change",
visuallyHiddenText: "account credentials"
}
Expand Down Expand Up @@ -94,7 +94,7 @@
actions: {
items: [
{
href: formatAccountPathsFor(routes.account.notificationCredentials.edit, currentGatewayAccount.external_id) + "?change=username",
href: routes.notificationCredentials.edit + "?change=username",
text: "Change",
visuallyHiddenText: "account credentials",
attributes: {
Expand All @@ -115,7 +115,7 @@
actions: {
items: [
{
href: formatAccountPathsFor(routes.account.notificationCredentials.edit, currentGatewayAccount.external_id) + "?change=password",
href: routes.notificationCredentials.edit + "?change=password",
text: "Change",
visuallyHiddenText: "account credentials"
}
Expand Down
6 changes: 3 additions & 3 deletions app/views/your-psp/_worldpay.njk
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
actions: {
items: [
{
href: formatAccountPathsFor(routes.account.credentials.edit, currentGatewayAccount.external_id) + "?change=merchantId",
href: routes.credentials.edit + "?change=merchantId",
text: "Change",
visuallyHiddenText: "account credentials",
attributes: {
Expand All @@ -38,7 +38,7 @@
actions: {
items: [
{
href: formatAccountPathsFor(routes.account.credentials.edit, currentGatewayAccount.external_id) + "?change=username",
href: routes.credentials.edit + "?change=username",
text: "Change",
visuallyHiddenText: "account credentials"
}
Expand All @@ -56,7 +56,7 @@
actions: {
items: [
{
href: formatAccountPathsFor(routes.account.credentials.edit, currentGatewayAccount.external_id) + "?change=password",
href: routes.credentials.edit + "?change=password",
text: "Change",
visuallyHiddenText: "account credentials"
}
Expand Down
2 changes: 1 addition & 1 deletion test/cypress/integration/settings/your-psp.cy.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ describe('Your PSP settings page', () => {
const gatewayAccountExternalId = 'a-valid-external-id'
const serviceName = 'Purchase a positron projection permit'
const yourPspPath = `/account/${gatewayAccountExternalId}/your-psp`

const testCredentials = {
merchant_id: 'positron-permit-people',
username: 'jonheslop',
Expand Down
Loading

0 comments on commit 82a630a

Please sign in to comment.