mirror of
https://github.com/mmumshad/ansible-playable.git
synced 2025-03-09 23:38:54 +00:00
Initial Commit
This commit is contained in:
commit
c92f737237
273 changed files with 16964 additions and 0 deletions
37
client/app/account/account.routes.js
Normal file
37
client/app/account/account.routes.js
Normal file
|
@ -0,0 +1,37 @@
|
|||
'use strict';
|
||||
|
||||
export default function routes($stateProvider) {
|
||||
'ngInject';
|
||||
|
||||
$stateProvider.state('login', {
|
||||
url: '/login',
|
||||
template: require('./login/login.html'),
|
||||
controller: 'LoginController',
|
||||
controllerAs: 'vm'
|
||||
})
|
||||
.state('logout', {
|
||||
url: '/logout?referrer',
|
||||
referrer: 'main',
|
||||
template: '',
|
||||
controller($state, Auth) {
|
||||
'ngInject';
|
||||
|
||||
var referrer = $state.params.referrer || $state.current.referrer || 'main';
|
||||
Auth.logout();
|
||||
$state.go(referrer);
|
||||
}
|
||||
})
|
||||
.state('signup', {
|
||||
url: '/signup',
|
||||
template: require('./signup/signup.html'),
|
||||
controller: 'SignupController',
|
||||
controllerAs: 'vm'
|
||||
})
|
||||
.state('settings', {
|
||||
url: '/settings',
|
||||
template: require('./settings/settings.html'),
|
||||
controller: 'SettingsController',
|
||||
controllerAs: 'vm',
|
||||
authenticate: true
|
||||
});
|
||||
}
|
24
client/app/account/index.js
Normal file
24
client/app/account/index.js
Normal file
|
@ -0,0 +1,24 @@
|
|||
'use strict';
|
||||
|
||||
import angular from 'angular';
|
||||
|
||||
import uiRouter from 'angular-ui-router';
|
||||
|
||||
import routing from './account.routes';
|
||||
import login from './login';
|
||||
import settings from './settings';
|
||||
import signup from './signup';
|
||||
import oauthButtons from '../../components/oauth-buttons';
|
||||
|
||||
export default angular.module('app2App.account', [uiRouter, login, settings, signup, oauthButtons])
|
||||
.config(routing)
|
||||
.run(function($rootScope) {
|
||||
'ngInject';
|
||||
|
||||
$rootScope.$on('$stateChangeStart', function(event, next, nextParams, current) {
|
||||
if(next.name === 'logout' && current && current.name && !current.authenticate) {
|
||||
next.referrer = current.name;
|
||||
}
|
||||
});
|
||||
})
|
||||
.name;
|
8
client/app/account/login/index.js
Normal file
8
client/app/account/login/index.js
Normal file
|
@ -0,0 +1,8 @@
|
|||
'use strict';
|
||||
|
||||
import angular from 'angular';
|
||||
import LoginController from './login.controller';
|
||||
|
||||
export default angular.module('app2App.login', [])
|
||||
.controller('LoginController', LoginController)
|
||||
.name;
|
38
client/app/account/login/login.controller.js
Normal file
38
client/app/account/login/login.controller.js
Normal file
|
@ -0,0 +1,38 @@
|
|||
'use strict';
|
||||
|
||||
export default class LoginController {
|
||||
user = {
|
||||
name: '',
|
||||
email: '',
|
||||
password: ''
|
||||
};
|
||||
errors = {
|
||||
login: undefined
|
||||
};
|
||||
submitted = false;
|
||||
|
||||
|
||||
/*@ngInject*/
|
||||
constructor(Auth, $state) {
|
||||
this.Auth = Auth;
|
||||
this.$state = $state;
|
||||
}
|
||||
|
||||
login(form) {
|
||||
this.submitted = true;
|
||||
|
||||
if(form.$valid) {
|
||||
this.Auth.login({
|
||||
email: this.user.email,
|
||||
password: this.user.password
|
||||
})
|
||||
.then(() => {
|
||||
// Logged in, redirect to home
|
||||
this.$state.go('main');
|
||||
})
|
||||
.catch(err => {
|
||||
this.errors.login = err.message;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
53
client/app/account/login/login.html
Normal file
53
client/app/account/login/login.html
Normal file
|
@ -0,0 +1,53 @@
|
|||
<div class="container">
|
||||
<div class="row">
|
||||
<div class="col-sm-12">
|
||||
<h1>Login</h1>
|
||||
<p>Accounts are reset on server restart from <code>server/config/seed.js</code>. Default account is <code>test@example.com</code> / <code>test</code></p>
|
||||
<p>Admin account is <code>admin@example.com</code> / <code>admin</code></p>
|
||||
</div>
|
||||
<div class="col-sm-12">
|
||||
<form class="form" name="form" ng-submit="vm.login(form)" novalidate>
|
||||
|
||||
<div class="form-group">
|
||||
<label>Email</label>
|
||||
|
||||
<input type="email" name="email" class="form-control" ng-model="vm.user.email" required>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label>Password</label>
|
||||
|
||||
<input type="password" name="password" class="form-control" ng-model="vm.user.password" required>
|
||||
</div>
|
||||
|
||||
<div class="form-group has-error">
|
||||
<p class="help-block" ng-show="form.email.$error.required && form.password.$error.required && vm.submitted">
|
||||
Please enter your email and password.
|
||||
</p>
|
||||
<p class="help-block" ng-show="form.email.$error.email && vm.submitted">
|
||||
Please enter a valid email.
|
||||
</p>
|
||||
|
||||
<p class="help-block">{{ vm.errors.login }}</p>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<button class="btn btn-inverse btn-lg btn-login" type="submit">
|
||||
Login
|
||||
</button>
|
||||
<a class="btn btn-default btn-lg btn-register" ui-sref="signup">
|
||||
Register
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<hr/>
|
||||
<div class="row">
|
||||
<div class="col-sm-4 col-md-3">
|
||||
<oauth-buttons classes="btn-block"></oauth-buttons>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<hr>
|
||||
</div>
|
8
client/app/account/settings/index.js
Normal file
8
client/app/account/settings/index.js
Normal file
|
@ -0,0 +1,8 @@
|
|||
'use strict';
|
||||
|
||||
import angular from 'angular';
|
||||
import SettingsController from './settings.controller';
|
||||
|
||||
export default angular.module('app2App.settings', [])
|
||||
.controller('SettingsController', SettingsController)
|
||||
.name;
|
36
client/app/account/settings/settings.controller.js
Normal file
36
client/app/account/settings/settings.controller.js
Normal file
|
@ -0,0 +1,36 @@
|
|||
'use strict';
|
||||
|
||||
export default class SettingsController {
|
||||
user = {
|
||||
oldPassword: '',
|
||||
newPassword: '',
|
||||
confirmPassword: ''
|
||||
};
|
||||
errors = {
|
||||
other: undefined
|
||||
};
|
||||
message = '';
|
||||
submitted = false;
|
||||
|
||||
|
||||
/*@ngInject*/
|
||||
constructor(Auth) {
|
||||
this.Auth = Auth;
|
||||
}
|
||||
|
||||
changePassword(form) {
|
||||
this.submitted = true;
|
||||
|
||||
if(form.$valid) {
|
||||
this.Auth.changePassword(this.user.oldPassword, this.user.newPassword)
|
||||
.then(() => {
|
||||
this.message = 'Password successfully changed.';
|
||||
})
|
||||
.catch(() => {
|
||||
form.password.$setValidity('mongoose', false);
|
||||
this.errors.other = 'Incorrect password';
|
||||
this.message = '';
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
51
client/app/account/settings/settings.html
Normal file
51
client/app/account/settings/settings.html
Normal file
|
@ -0,0 +1,51 @@
|
|||
<div class="container">
|
||||
<div class="row">
|
||||
<div class="col-sm-12">
|
||||
<h1>Change Password</h1>
|
||||
</div>
|
||||
<div class="col-sm-12">
|
||||
<form class="form" name="form" ng-submit="vm.changePassword(form)" novalidate>
|
||||
|
||||
<div class="form-group">
|
||||
<label>Current Password</label>
|
||||
|
||||
<input type="password" name="password" class="form-control" ng-model="vm.user.oldPassword"
|
||||
mongoose-error/>
|
||||
<p class="help-block" ng-show="form.password.$error.mongoose">
|
||||
{{ vm.errors.other }}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label>New Password</label>
|
||||
|
||||
<input type="password" name="newPassword" class="form-control" ng-model="vm.user.newPassword"
|
||||
ng-minlength="3"
|
||||
required/>
|
||||
<p class="help-block"
|
||||
ng-show="(form.newPassword.$error.minlength || form.newPassword.$error.required) && (form.newPassword.$dirty || vm.submitted)">
|
||||
Password must be at least 3 characters.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label>Confirm New Password</label>
|
||||
|
||||
<input type="password" name="confirmPassword" class="form-control" ng-model="vm.user.confirmPassword"
|
||||
match="vm.user.newPassword"
|
||||
ng-minlength="3"
|
||||
required=""/>
|
||||
<p class="help-block"
|
||||
ng-show="form.confirmPassword.$error.match && vm.submitted">
|
||||
Passwords must match.
|
||||
</p>
|
||||
|
||||
</div>
|
||||
|
||||
<p class="help-block"> {{ vm.message }} </p>
|
||||
|
||||
<button class="btn btn-lg btn-primary" type="submit">Save changes</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
8
client/app/account/signup/index.js
Normal file
8
client/app/account/signup/index.js
Normal file
|
@ -0,0 +1,8 @@
|
|||
'use strict';
|
||||
|
||||
import angular from 'angular';
|
||||
import SignupController from './signup.controller';
|
||||
|
||||
export default angular.module('app2App.signup', [])
|
||||
.controller('SignupController', SignupController)
|
||||
.name;
|
45
client/app/account/signup/signup.controller.js
Normal file
45
client/app/account/signup/signup.controller.js
Normal file
|
@ -0,0 +1,45 @@
|
|||
'use strict';
|
||||
|
||||
import angular from 'angular';
|
||||
|
||||
export default class SignupController {
|
||||
user = {
|
||||
name: '',
|
||||
email: '',
|
||||
password: ''
|
||||
};
|
||||
errors = {};
|
||||
submitted = false;
|
||||
|
||||
|
||||
/*@ngInject*/
|
||||
constructor(Auth, $state) {
|
||||
this.Auth = Auth;
|
||||
this.$state = $state;
|
||||
}
|
||||
|
||||
register(form) {
|
||||
this.submitted = true;
|
||||
|
||||
if(form.$valid) {
|
||||
return this.Auth.createUser({
|
||||
name: this.user.name,
|
||||
email: this.user.email,
|
||||
password: this.user.password
|
||||
})
|
||||
.then(() => {
|
||||
// Account created, redirect to home
|
||||
this.$state.go('main');
|
||||
})
|
||||
.catch(err => {
|
||||
err = err.data;
|
||||
this.errors = {};
|
||||
// Update validity of form fields that match the mongoose errors
|
||||
angular.forEach(err.errors, (error, field) => {
|
||||
form[field].$setValidity('mongoose', false);
|
||||
this.errors[field] = error.message;
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
86
client/app/account/signup/signup.html
Normal file
86
client/app/account/signup/signup.html
Normal file
|
@ -0,0 +1,86 @@
|
|||
<div class="container">
|
||||
<div class="row">
|
||||
<div class="col-sm-12">
|
||||
<h1>Sign up</h1>
|
||||
</div>
|
||||
<div class="col-sm-12">
|
||||
<form class="form" name="form" ng-submit="vm.register(form)" novalidate>
|
||||
|
||||
<div class="form-group" ng-class="{ 'has-success': form.name.$valid && vm.submitted,
|
||||
'has-error': form.name.$invalid && vm.submitted }">
|
||||
<label>Name</label>
|
||||
|
||||
<input type="text" name="name" class="form-control" ng-model="vm.user.name"
|
||||
required/>
|
||||
<p class="help-block" ng-show="form.name.$error.required && vm.submitted">
|
||||
A name is required
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div class="form-group" ng-class="{ 'has-success': form.email.$valid && vm.submitted,
|
||||
'has-error': form.email.$invalid && vm.submitted }">
|
||||
<label>Email</label>
|
||||
|
||||
<input type="email" name="email" class="form-control" ng-model="vm.user.email"
|
||||
required
|
||||
mongoose-error/>
|
||||
<p class="help-block" ng-show="form.email.$error.email && vm.submitted">
|
||||
Doesn't look like a valid email.
|
||||
</p>
|
||||
<p class="help-block" ng-show="form.email.$error.required && vm.submitted">
|
||||
What's your email address?
|
||||
</p>
|
||||
<p class="help-block" ng-show="form.email.$error.mongoose">
|
||||
{{ vm.errors.email }}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div class="form-group" ng-class="{ 'has-success': form.password.$valid && vm.submitted,
|
||||
'has-error': form.password.$invalid && vm.submitted }">
|
||||
<label>Password</label>
|
||||
|
||||
<input type="password" name="password" class="form-control" ng-model="vm.user.password"
|
||||
ng-minlength="3"
|
||||
required
|
||||
mongoose-error/>
|
||||
<p class="help-block"
|
||||
ng-show="(form.password.$error.minlength || form.password.$error.required) && vm.submitted">
|
||||
Password must be at least 3 characters.
|
||||
</p>
|
||||
<p class="help-block" ng-show="form.password.$error.mongoose">
|
||||
{{ vm.errors.password }}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div class="form-group" ng-class="{ 'has-success': form.confirmPassword.$valid && vm.submitted,
|
||||
'has-error': form.confirmPassword.$invalid && vm.submitted }">
|
||||
<label>Confirm Password</label>
|
||||
<input type="password" name="confirmPassword" class="form-control" ng-model="vm.user.confirmPassword"
|
||||
match="vm.user.password"
|
||||
ng-minlength="3" required/>
|
||||
<p class="help-block"
|
||||
ng-show="form.confirmPassword.$error.match && vm.submitted">
|
||||
Passwords must match.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<button class="btn btn-inverse btn-lg btn-register" type="submit">
|
||||
Sign up
|
||||
</button>
|
||||
<a class="btn btn-default btn-lg btn-login" ui-sref="login">
|
||||
Login
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<hr/>
|
||||
<div class="row">
|
||||
<div class="col-sm-4 col-md-3">
|
||||
<oauth-buttons classes="btn-block"></oauth-buttons>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<hr>
|
||||
</div>
|
Loading…
Add table
Add a link
Reference in a new issue