Skip to content

Commit

Permalink
Merge pull request #114 from Kondeo/leading0
Browse files Browse the repository at this point in the history
Leading0 Bugfix
  • Loading branch information
julianpoy committed May 29, 2016
2 parents 41f0c9e + bd5f368 commit da10c05
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 28 deletions.
46 changes: 30 additions & 16 deletions app/scripts/controllers/register.js
Original file line number Diff line number Diff line change
Expand Up @@ -402,10 +402,12 @@ angular.module('starter')
//Create finalized card number
var cardNumber = $scope.registerData.ccNumber;

var cardCvv = document.getElementById("cardCvv");

//Send card info to stripe for tokenization
Stripe.card.createToken({
"number": $scope.registerData.ccNumber,
"cvc": $scope.registerData.cvv,
"cvc": cardCvv.value,
"exp_month": $scope.registerData.expireM,
"exp_year": $scope.registerData.expireY
}, function(status, response) {
Expand All @@ -417,7 +419,7 @@ angular.module('starter')
//Stop loading
loadingSpinner.stopLoading();

Notifications.show("Card Error", "Please check your card information.");
Notifications.show("Card Could Not Be Verified", "Please check your card information.");

} else {

Expand Down Expand Up @@ -477,8 +479,18 @@ angular.module('starter')
var handlers = [
{
status: 406,
title: "Email Taken",
text: "Sorry, that email has been taken. Please enter another email!",
title: "Email Unsupported",
text: "Sorry, that email format isn't supported by our system. Please enter another email with a common provider!",
callback: function() {

//Ng class red email text
$scope.emailError = true;
}
},
{
status: 409,
title: "Email Already Registered",
text: "Sorry, that email has already been registered to an account. Please enter another email, or use the existing account!",
callback: function() {

//Ng class red email text
Expand All @@ -487,8 +499,8 @@ angular.module('starter')
},
{
status: 402,
title: "Card was declined",
text: "Please check your card information.",
title: "Card Declined by Stripe",
text: "We could not properly charge your card. Please check your card information.",
callback: function() {

//Display alert, and show card errors
Expand All @@ -507,8 +519,8 @@ angular.module('starter')
},
{
status: 417,
title: "Membership Username/Password Incorrect",
text: "Please check your membership information.",
title: "Membership Username or Password Incorrect",
text: "Please check your CCRA membership credentials. If you are not a CCRA member, please uncheck 'I am a CCRA member'.",
callback: function() {

//Display alert, and show card errors
Expand Down Expand Up @@ -544,17 +556,19 @@ angular.module('starter')
//Create finalized card number
var cardNumber = $scope.registerData.ccNumber;

var cardCvv = document.getElementById("cardCvv");

//Send card info to stripe for tokenization
Stripe.card.createToken({
"number": $scope.registerData.ccNumber,
"cvc": $scope.registerData.cvv,
"cvc": cardCvv.value,
"exp_month": $scope.registerData.expireM,
"exp_year": $scope.registerData.expireY
}, function(status, response) {
if (response.error) {

//Show an error for the card
Notifications.show("Card Error", "Please check your card information.");
Notifications.show("Card Could Not Be Verified", "Please check your card information.");

//Display alert
$scope.cardError = true;
Expand Down Expand Up @@ -614,8 +628,8 @@ angular.module('starter')
var handlers = [
{
status: 401,
title: "Authentication Error",
text: "Please check your email and password.",
title: "Incorrect Email or Password",
text: "Please check your email and password. You need to use the same email and password you signed up with.",
callback: function() {

//show red ng class text
Expand All @@ -625,8 +639,8 @@ angular.module('starter')
},
{
status: 402,
title: "Card was declined",
text: "Please check your card information.",
title: "Card Declined by Stripe",
text: "We could not properly charge your card. Please check your card information.",
callback: function() {

//Display alert, and show card errors
Expand All @@ -645,8 +659,8 @@ angular.module('starter')
},
{
status: 417,
title: "Membership Username/Password Incorrect",
text: "Please check your membership information.",
title: "Membership Username or Password Incorrect",
text: "Please check your CCRA membership credentials. If you are not a CCRA member, please uncheck 'I am a CCRA member'.",
callback: function() {

//Display alert, and show card errors
Expand Down
4 changes: 2 additions & 2 deletions backend/config/constants.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"VERSION": {
"NUMBER": "0.1.7",
"DEPRICATED": "0.1.6",
"NUMBER": "0.1.8",
"DEPRICATED": "0.1.7",
"LAST_COMPATIBLE": "0.1.7"
},
"SUBSCRIPTION_PRICE": {
Expand Down
19 changes: 12 additions & 7 deletions backend/routes/users.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ router.post('/register', function(req, res) {
var cleanEmail = (req.body.email.toLowerCase()).trim();
var emailRegex = /[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+(?:[A-Z]{2}|com|org|net|edu|gov|mil|biz|info|mobi|name|aero|asia|jobs|museum)\b/;
if (!emailRegex.test(cleanEmail)) {
res.status(412).json({
res.status(406).json({
msg: "Email is not valid!"
});
} else {
Expand All @@ -38,7 +38,7 @@ router.post('/register', function(req, res) {
.select('_id')
.exec(function(err, user) {
if (user) {
res.status(406).json({
res.status(409).json({
msg: "Email taken!"
});
} else {
Expand All @@ -52,7 +52,10 @@ router.post('/register', function(req, res) {
}

function finalizeReg(isMember){
if(isMember) plan = "member";
if(isMember) {
plan = "member";
isMember = true;
};

StripeService.createCustomer(req.body.cardToken, plan, (req.body.email.toLowerCase()).trim(), function(customer){
//Create a random salt
Expand Down Expand Up @@ -201,7 +204,10 @@ router.post('/sub/add', function(req, res, next) {

function clearSubs(membership){
isMember = membership;
if(isMember) plan = "member";
if(isMember) {
plan = "member";
isMember = true;
}
if(user.subscriptionId){
StripeService.unsubscribe(user.subscriptionId, getStripeId, function(){
res.status(500).json({
Expand All @@ -216,7 +222,6 @@ router.post('/sub/add', function(req, res, next) {
function getStripeId(){
if(!user.stripeId){
StripeService.createCustomer(null, null, (req.body.email.toLowerCase()).trim(), function(customer){
console.log(customer)
newSub(customer.id);
}, function(err){
res.status(402).json({
Expand Down Expand Up @@ -371,7 +376,7 @@ router.get('/self/:token', function(req, res, next) {
router.put('/self/:token', function(req, res, next) {
var emailRegex = /[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+(?:[A-Z]{2}|com|org|net|edu|gov|mil|biz|info|mobi|name|aero|asia|jobs|museum)\b/;
if (req.body.email && !emailRegex.test(req.body.email)) {
res.status(412).json({
res.status(406).json({
msg: "Email is not valid!"
});
} else {
Expand Down Expand Up @@ -415,7 +420,7 @@ router.post('/forgot', function(req, res, next) {
//Find a user with the username requested. Select salt and password
var emailRegex = /[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+(?:[A-Z]{2}|com|org|net|edu|gov|mil|biz|info|mobi|name|aero|asia|jobs|museum)\b/;
if (!emailRegex.test(req.body.email)) {
res.status(412).json({
res.status(406).json({
msg: "Email is not valid!"
});
} else {
Expand Down
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "CCRAECompendium",
"version": "0.1.7",
"version": "0.1.8",
"dependencies": {
"angular-animate": "1.5.3",
"angular-hotkeys": "chieffancypants/angular-hotkeys#~1.6.0",
Expand Down
2 changes: 1 addition & 1 deletion config.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<widget id="com.Kondeo.CCRAECompendium" version="0.1.7" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
<widget id="com.Kondeo.CCRAECompendium" version="0.1.8" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
<name>Compendium</name>
<description>
CCRA ECompendium
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "CCRAECompendium",
"version": "0.1.7",
"version": "0.1.8",
"private": true,
"dependencies": {
"moment": "^2.11.1"
Expand Down

0 comments on commit da10c05

Please sign in to comment.