-
-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: implemented user auth using Identity
- Loading branch information
Showing
22 changed files
with
27,595 additions
and
18,165 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,38 @@ | ||
/// <reference types="cypress" /> | ||
|
||
context('Check Navbar Items', () => { | ||
before(() => { | ||
cy.visit('http://localhost:8080') | ||
cy.get('[data-cy=timeline]').click() | ||
}) | ||
before(() => { | ||
cy.visit('http://localhost:8080') | ||
cy.get('[data-cy=timeline]').click() | ||
}) | ||
|
||
it('Should have a search bar', () => { | ||
cy.get('[data-cy=container').find("#searchbar") | ||
}) | ||
it('Should have a search bar', () => { | ||
cy.get('[data-cy=container').find('#searchbar') | ||
}) | ||
|
||
it('Should be a download off button', () => { | ||
const t = cy.get('[data-cy=download-off]') | ||
expect(t).to.exist | ||
}) | ||
it('Should be a download off button', () => { | ||
const t = cy.get('[data-cy=download-off]') | ||
expect(t).to.exist | ||
}) | ||
|
||
it('Should be a heart button', () => { | ||
const t = cy.get('[data-cy=heart]') | ||
expect(t).to.exist | ||
}) | ||
it('Should be a heart button', () => { | ||
const t = cy.get('[data-cy=heart]') | ||
expect(t).to.exist | ||
}) | ||
|
||
it('Should be a bell button', () => { | ||
const t = cy.get('[data-cy=bell]') | ||
expect(t).to.exist | ||
}) | ||
it('Should be a bell button', () => { | ||
const t = cy.get('[data-cy=bell]') | ||
expect(t).to.exist | ||
}) | ||
|
||
it('Should be an about button', () => { | ||
const t = cy.get('[data-cy=about]') | ||
expect(t).to.exist | ||
}) | ||
it('Should have user profile component card', () => { | ||
const t = cy.get('[data-cy=profile-component]') | ||
expect(t).to.exist | ||
}) | ||
|
||
it('Should have a five links', () => { | ||
cy.get('[data-cy=drawer]').then(($result) => { | ||
assert.equal($result.children().children()[0].childElementCount,5,'Five links in the drawer') | ||
}) | ||
it('Should have a five links', () => { | ||
cy.get('[data-cy=drawer]').then(($result) => { | ||
assert.equal($result.children().children()[0].childElementCount, 5, 'Five links in the drawer') | ||
}) | ||
}) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/// <reference types="cypress" /> | ||
|
||
context('Profile menu', () => { | ||
before(() => { | ||
cy.visit('http://localhost:8080/timeline') | ||
}) | ||
|
||
it('Should start authentication with Auth0', () => { | ||
cy.get('[data-cy=display-profile]').click() | ||
|
||
}) | ||
|
||
it('Confirm Profile Card Elements', () => { | ||
cy.get('[data-cy=profile-toggle]').click() | ||
cy.get('.v-list-item__title') | ||
.should('contain.text', 'Test User') | ||
|
||
cy.get('.v-list-item__subtitle') | ||
.should('contain.text', 'test@gmail.com') | ||
|
||
cy.get('[data-cy=logout-button]').should('be.visible') | ||
}) | ||
|
||
it('Should open subscription modal', () => { | ||
cy.get('[data-cy=add-subscription]').click() | ||
cy.get('[data-cy=dismiss-modal]').click() | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/// <reference types="cypress" /> | ||
|
||
context('SubscriptionModal', () => { | ||
before(() => { | ||
cy.visit('http://localhost:8080/timeline') | ||
}) | ||
|
||
it('Should launch subscription modal', () => { | ||
cy.get('[data-cy=auth-btn]').click() | ||
}) | ||
|
||
it('It displays input fields', () => { | ||
cy.get('[data-cy=subscribe]').click() | ||
|
||
cy.get('[name=cardHolderName]').should('be.visible') | ||
cy.get('[name=cardNumber]').should('be.visible') | ||
cy.get('[name=emailAddress]').should('be.visible') | ||
}) | ||
|
||
it('It validates card-number regex is functional', () => { | ||
cy.get('[data-cy=confirm-btn]').should('be.disabled') | ||
|
||
cy.get('[name=cardNumber]').type('4242424242424242') | ||
|
||
cy.get('[data-cy=confirm-btn]').should('be.enabled') | ||
}) | ||
|
||
it('It contains 7 input forms', () => { | ||
cy.get('input').its('length').should('be.eq', 7) | ||
}) | ||
|
||
it('should dismiss subscription modal', () => { | ||
cy.get('[data-cy=dismiss-modal]').click() | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
[build] | ||
command = "npm run build" | ||
functions = "netlify/functions" | ||
|
||
[[headers]] | ||
for = "/*" | ||
[headers.values] | ||
Access-Control-Allow-Origin = "*" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
require('dotenv').config() | ||
const stripe = require('stripe')(process.env.STRIPE_TEST_KEY) | ||
|
||
exports.handler = (event, context, callback) => { | ||
const { stripeId } = event.queryStringParameters | ||
stripe.subscriptions.del(stripeId).then(() => { | ||
return callback(null, { | ||
statusCode: 200, | ||
body: JSON.stringify({ message: 'CUSTOMER HAS BEEN UNSUBSCRIBED' }) | ||
}) | ||
}) | ||
.catch(error => { | ||
callback(null, { | ||
statusCode: 422, | ||
body: JSON.stringify({ message: 'ERROR GETTING CUSTOMERS', error }) | ||
}) | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
require('dotenv').config() | ||
const stripe = require('stripe')(process.env.STRIPE_TEST_KEY) | ||
|
||
const headers = { | ||
'Access-Control-Allow-Origin': '*', | ||
'Access-Control-Allow-Headers': 'Content-Type', | ||
'Access-Control-Allow-Methods': 'GET, POST, PUT, DELETE' | ||
} | ||
|
||
exports.handler = (event, context, callback) => { | ||
stripe.customers | ||
.list() | ||
.then(customers => { | ||
return callback(null, { | ||
statusCode: 200, | ||
headers, | ||
body: JSON.stringify({ customers }) | ||
}) | ||
}) | ||
.catch(error => callback(null, { | ||
statusCode: 422, | ||
headers, | ||
body: JSON.stringify({ message: 'ERROR GETTING CUSTOMERS', error }) | ||
})) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
require('dotenv').config() | ||
const stripe = require('stripe')(process.env.STRIPE_TEST_KEY) | ||
|
||
const headers = { | ||
'Access-Control-Allow-Origin': '*', | ||
'Access-Control-Allow-Headers': 'Content-Type', | ||
'Access-Control-Allow-Methods': 'GET, POST, PUT, DELETE' | ||
} | ||
|
||
// TODO: Refactor to use async await. | ||
exports.handler = (event, context, callback) => { | ||
const { email, card } = event.queryStringParameters | ||
|
||
// eslint-disable-next-line camelcase | ||
const { number, cvc, exp_month, exp_year } = JSON.parse(card) | ||
|
||
stripe.sources.create({ | ||
type: 'ach_credit_transfer', | ||
currency: 'usd', | ||
owner: { | ||
} | ||
}, (err, source) => { | ||
if (err) { | ||
console.log(err) | ||
} | ||
// Create a payment method for user using the Card Details | ||
stripe.paymentMethods.create({ | ||
type: 'card', | ||
card: { | ||
number, cvc, exp_year, exp_month | ||
} | ||
}).then(({ id: paymentID }) => { | ||
// Creates Customer ==> | ||
stripe.customers | ||
.create({ | ||
email, | ||
description: 'Ambianic customer using premium service', | ||
payment_method: paymentID, | ||
source: source.id | ||
}) | ||
.then(({ id: customerID }) => { | ||
stripe.paymentMethods.attach(paymentID, { customer: customerID }).then((data) => { | ||
stripe.subscriptions.create({ | ||
customer: customerID, | ||
items: [{ | ||
price: process.env.EMAIL_PRODUCT_ID | ||
}] | ||
}).then(() => callback(null, { | ||
statusCode: 200, | ||
headers, | ||
body: JSON.stringify({ message: 'EMAIl SUBSCRIPTION CREATED' }) | ||
})).catch(e => { | ||
console.log(`Err creating subscription : ${e}`) | ||
}) | ||
}).catch(e => { | ||
console.log(`Creating customer ${e}`) | ||
}) | ||
}) | ||
}).catch(error => callback(null, { | ||
statusCode: 422, | ||
headers, | ||
body: JSON.stringify({ message: 'ERROR CREATING USER', error }) | ||
})) | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"name": "functions", | ||
"version": "1.0.0", | ||
"main": "index.js", | ||
"license": "MIT", | ||
"dependencies": { | ||
"stripe": "^8.135.0" | ||
} | ||
} |
Oops, something went wrong.