Skip to content

Commit

Permalink
Merge branch 'release/v1.6.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
GreenPioneer committed Feb 7, 2017
2 parents d84e335 + 0f18ad0 commit 0d08be8
Show file tree
Hide file tree
Showing 29 changed files with 560 additions and 650 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ files/
# --------------------
client/styles/compiled
client/scripts/compiled
client/styles/downloaded
client/scripts/downloaded

# --------------------
# Babel Compiled files
Expand All @@ -96,3 +98,6 @@ tools/nightwatch/reports/index.html
database/
downloads/
backups/

# ENV
.env
33 changes: 17 additions & 16 deletions bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,25 +15,26 @@
"angular-cookies": "1.5.8",
"angular-animate": "1.5.8",
"angular-resource": "1.5.8",
"angular-material": "~1.0.1",
"angular-material": "1.0.1",
"angular-mocks": "1.5.8",
"angular-moment": "^1.0.0-beta.6",
"angular-ui-router": "^0.3.1",
"angular-bootstrap": "^2.0.0",
"bootstrap-sass": "~3.3.7",
"font-awesome": "^4.3.0",
"foundation": "~5.5.3",
"lodash": "~4.14.0",
"jquery": "^3.1.0",
"moment": "^2.14.1",
"materialize": "^0.97.7",
"toastr": "^2.1.2",
"ng-file-upload": "^12.0.4",
"socket.io-client": "~1.4.5",
"angular-jwt": "^0.0.9"
"angular-moment": "1.0.1",
"angular-ui-router": "0.3.2",
"angular-bootstrap": "2.0.0",
"bootstrap-sass": "3.3.7",
"font-awesome": "4.3.0",
"foundation": "5.5.3",
"lodash": "4.17.4",
"jquery": "3.1.0",
"moment": "2.14.1",
"materialize": "0.97.7",
"toastr": "^2.1.3",
"ng-file-upload": "12.0.4",
"socket.io-client": "1.4.5",
"angular-jwt": "0.0.9",
"ngBrowserInfo": "ng-browser-info#^0.1.4"
},
"resolutions": {
"angular": "1.5.8",
"jquery": "^3.1.0"
"jquery": "3.1.0"
}
}
2 changes: 1 addition & 1 deletion client/modules/blog/blog.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ describe('BLOG Testing', function () {
$httpBackend = _$httpBackend_
$stateParams = _$stateParams_
$location = _$location_
$httpBackend.when('GET', /\/api\/authenticate\?noCache=\d+/)
$httpBackend.when('GET', /\/api\/user\/authenticate\?noCache=\d+/)
.respond(200, authResponse)
$httpBackend.when('GET', /\/api\/seo\/*/)
.respond(200, {})
Expand Down
3 changes: 2 additions & 1 deletion client/modules/core/core.module.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
'ui.router',
'angularMoment',
'ngFileUpload',
'angular-jwt'
'angular-jwt',
'ngBrowserInfo'
])
})()
13 changes: 13 additions & 0 deletions client/modules/core/core.route.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,19 @@
templateUrl: 'modules/core/500.view.html',
title: '500'
}
},
{
state: 'debug',
config: {
url: '/debug',
templateUrl: 'modules/core/debug.view.html',
title: 'debug',
controllerAs: 'vm',
controller: function (browserInfo) {
var vm = this
vm.browserInfo = browserInfo
}
}
}
]
}
Expand Down
5 changes: 5 additions & 0 deletions client/modules/core/debug.view.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<div class="container">
<h2>Browser Debug Information</h2>
<p>Please copy and paste this information below. Email it to <a href="mailto:[email protected]?Subject=Debug Information">Your Domain Admin</a></p>
<pre>{{vm.browserInfo.giveMeAllYouGot()|json}}</pre>
</div>
7 changes: 2 additions & 5 deletions client/modules/footer/footer.view.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,8 @@
<a href="https://github.com/GreenPioneer/meanstackjs">
<span class="fa fa-github-alt"></span> Github
</a>
<a href="https://twitter.com/greenpioneerdev">
<span class="fa fa-twitter"></span> @greenpioneerdev
</a>
<a href="https://twitter.com/cqdinh425">
<span class="fa fa-twitter"></span> @cqdinh425
<a href="https://twitter.com/meanstackjs">
<span class="fa fa-twitter"></span> @meanstackjs
</a>
</div>
</footer>
4 changes: 2 additions & 2 deletions client/modules/header/header.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ describe('HEADER Testing', function () {
beforeEach(inject(function (_$httpBackend_, $controller, $rootScope, _UserFactory_) {
UserFactory = _UserFactory_
$httpBackend = _$httpBackend_
$httpBackend.whenGET(/\/api\/logout\?noCache=\d+/)
$httpBackend.whenGET(/\/api\/user\/logout\?noCache=\d+/)
.respond(200, '')
$httpBackend.whenGET(/\/api\/authenticate\?noCache=\d+/)
$httpBackend.whenGET(/\/api\/user\/authenticate\?noCache=\d+/)
.respond(200, authResponse)
$httpBackend.when('GET', /\/api\/seo\/*/)
.respond(200, {})
Expand Down
30 changes: 26 additions & 4 deletions client/modules/user/account.view.html
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,31 @@ <h3>Profile Information</h3>
</div>
</div>
</form>

<div class="form-horizontal">
<div class="form-group">
<label for="token" class="col-sm-2 control-label">API Token</label>
<div class="col-sm-4">
<textarea type="text" rows="5" name="token" id="token" ng-model="vm.UserFactory.token" class="form-control" disabled="disabled"></textarea>
</div>
<div class="col-sm-offset-2 col-sm-8">
<button class="btn btn btn-info" ng-click="vm.refreshApiToken()"><i class="fa fa-refresh"></i>Refresh API Token</button>
</div>
</div>
<div class="form-group">
<!-- <div class="col-sm-offset-2 col-sm-6">
<p ng-show="!vm.editProfile.connected.azure"><a href="/api/auth/link/azure" target="_parent">Link your Azure account</a></p>
<p ng-show="vm.editProfile.connected.azure"><a href="/api/auth/unlink/azure" target="_parent">Unlink your Azure account</a></p>
</div>
<div class="col-sm-offset-2 col-sm-6">
<p ng-show="!vm.editProfile.connected.google"><a href="/api/auth/link/google" target="_parent">Link your Google account</a></p>
<p ng-show="vm.editProfile.connected.google"><a href="/api/auth/unlink/google" target="_parent">Unlink your Google account</a></p>
</div> -->
</div>
</div>
<!-- <div class="page-header">
<h3>Change Password</h3></div>
<form action="/account/password" method="POST" class="form-horizontal">
<form action="/user/password" method="POST" class="form-horizontal">
<div class="form-group">
<label for="password" class="col-sm-3 control-label">New Password</label>
<div class="col-sm-4">
Expand All @@ -71,16 +93,16 @@ <h3>Change Password</h3></div>
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-3 col-sm-4">
<div class="col-sm-offset-2 col-sm-6">
<button type="submit" class="btn btn btn-primary"><i class="fa fa-lock"></i>Change Password</button>
</div>
</div>
</form>
<div class="page-header">
<h3>Delete Account</h3></div>
<p>You can delete your account, but keep in mind this action is irreversible.</p>
<form action="/account/delete" method="POST">
<input type="hidden" name="_csrf" value="QLYIBDmu6z6uVBmLttJULTW+KxTL04K6X3j8s=">
<form action="/user/delete" method="POST">
<input type="hidden" >
<button type="submit" class="btn btn-danger"><i class="fa fa-trash"></i>Delete my account</button>
</form> -->

Expand Down
6 changes: 5 additions & 1 deletion client/modules/user/user.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@
/* @ngInject */
function UserController ($scope, $http, $cookies, config, $state, $timeout, UserFactory, logger, Upload, $stateParams) {
var vm = this
vm.resetCred = vm.editProfile = vm.loginCred = vm.loginError = {}
vm.resetCred = vm.editProfile = vm.loginCred = {}
vm.UserFactory = UserFactory
vm.refreshApiToken = function () {
UserFactory.resetApiToken()
}
vm.find = function () {
vm.editProfile = angular.copy(UserFactory.user)
}
Expand Down
72 changes: 38 additions & 34 deletions client/modules/user/user.factory.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,10 @@
function getAuthenticate () {
var deferred = $q.defer()

$http.get('/api/authenticate').then(function (success) {
$http.get('/api/user/authenticate').then(function (success) {
if (success.data) {
if (!_.isEmpty(success.data.user)) {
localStorage.setItem('JWT', success.data.token)
success.data.user = success.data.user
}
$timeout(deferred.resolve(success.data))
} else {
Expand All @@ -35,17 +34,13 @@
}

function UserClass () {
this.name = 'users'
this.user = {}
this.registerForm = false
this.loggedin = false
this.isAdmin = false
this.loginError = false
this.usernameError = false
this.registerError = false
this.resetpassworderror = false
this.validationError = false
self = this
self.name = 'users'
self.user = {}
self.token
self.loggedin = false
self.isAdmin = false

getAuthenticate().then(function (data) {
if (!data && $cookies.get('token') && $cookies.get('redirect')) {
self.onIdentity.bind(self)({
Expand All @@ -70,7 +65,7 @@
})
}
UserClass.prototype.login = function (vm) {
$http.post('/api/login', {
$http.post('/api/user/authenticate', {
email: vm.loginCred.email,
password: vm.loginCred.password,
redirect: $stateParams.redirect || '/'
Expand All @@ -87,12 +82,11 @@
UserClass.prototype.onIdentity = function (data) {
if (!data) return ({error: true})

this.user = data.user
this.loggedin = data.authenticated
this.loginError = false
this.registerError = false
if (this.user.roles) {
this.isAdmin = this.user.roles.indexOf('admin') > -1
self.user = data.user
self.token = data.token
self.loggedin = data.authenticated
if (self.user.roles) {
self.isAdmin = self.user.roles.indexOf('admin') > -1
}
if (data.redirect ? data.redirect : false) {
$location.url(data.redirect)
Expand All @@ -105,32 +99,29 @@

UserClass.prototype.onIdFail = function (error) {
logger.error(error.data.msg || error.data.message, error, 'Login/Signup')
this.loginError = 'Authentication failed.'
this.registerError = error
$rootScope.$emit('loginfailed')
$rootScope.$emit('registerfailed')
return ({
error: true
})
}

UserClass.prototype.updateProfile = function (response) {
var data = response.data || response
logger.success(data.user.profile.name + ' your profile has be saved', data, 'Updated Profile')
this.user = response.data.user
UserClass.prototype.updateProfile = function (data, response) {
self.user = data
logger.success(self.user.profile.name + ' your profile has be saved', self.user, 'Updated Profile')
$rootScope.$emit('profileUpdated')
}
UserClass.prototype.error = function (error) {
logger.error(error.data, error, 'User Error')
}
UserClass.prototype.update = function (vm) {
$http.put('/api/account/profile', vm.editProfile)
.then(this.updateProfile.bind(this), this.error.bind(this))
$http.put('/api/user/profile', vm.editProfile)
.then(self.updateProfile.bind(this, vm.editProfile), self.error.bind(this))
}
UserClass.prototype.signup = function (vm) {
if (vm.loginCred.password === vm.loginCred.confirmPassword) {
if ($stateParams.redirect)vm.loginCred.redirect = $stateParams.redirect
$http.post('/api/signup', vm.loginCred)
$http.post('/api/user/signup', vm.loginCred)
.then(function (success) {
if (!_.isEmpty(success.data.user)) {
localStorage.setItem('JWT', success.data.token)
Expand All @@ -146,7 +137,7 @@
}
}
UserClass.prototype.resetTokenCheck = function (vm) {
$http.get('/api/reset/' + vm.resetToken)
$http.get('/api/user/reset/' + vm.resetToken)
.then(
function (response) {
if (response.data.valid) {
Expand All @@ -159,10 +150,10 @@
)
}
UserClass.prototype.resetpassword = function (vm) {
$http.post('/api/reset/' + vm.resetToken, {
$http.post('/api/user/reset/' + vm.resetToken, {
password: vm.resetCred.password,
confirmPassword: vm.resetCred.confirmPassword
}).then(this.onIdentity.bind(this), this.onIdFail.bind(this))
}).then(self.onIdentity.bind(this), self.onIdFail.bind(this))
.then(function (response) {
if (!response.error) {
logger.success('Password successfully Reset', response)
Expand All @@ -171,21 +162,25 @@
}

UserClass.prototype.forgot = function (vm) {
$http.post('/api/forgot', {
$http.post('/api/user/forgot', {
email: vm.forgot.email
}).then(function (response) {
$rootScope.$emit('forgotmailsent', response)
logger.success(vm.forgot.email, vm.forgot.email, ' Reset Token has been sent to your email')
vm.clicked = true
vm.forgot.email = ''
}, this.onIdFail.bind(this))
}, self.onIdFail.bind(this))
}

UserClass.prototype.logout = function (vm) {
$http.get('/api/logout').then(function (data) {
$http.get('/api/user/logout').then(function (data) {
localStorage.removeItem('JWT')
$rootScope.$emit('logout')
// ANGULAR WAY
$state.go('index')
// ENTERPRISE WAY TO SUPPORT ALL OLDER BROWSERS
// var indexState = $state.get('index')
// window.location.href = indexState ? indexState.url : '/'
self.user = {}
self.loggedin = false
})
Expand Down Expand Up @@ -219,6 +214,15 @@
}
})
}
UserClass.prototype.resetApiToken = function () {
$http.get('/api/user/token/reset').then(function (success) {
self.token = success.data.token
localStorage.setItem('JWT', self.token)
}, function (error) {
logger.error('Unable to reset API Token', error, 'Server Error')
})
}

return UserFactory
}
}())
Loading

0 comments on commit 0d08be8

Please sign in to comment.