mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-11 09:53:32 +03:00
Merge pull request #2780 from jgable/ember-signup
Implement signup in Ember
This commit is contained in:
commit
2aad15373c
@ -1,5 +1,6 @@
|
|||||||
var ApplicationController = Ember.Controller.extend({
|
var ApplicationController = Ember.Controller.extend({
|
||||||
isSignedIn: Ember.computed.bool('user.isSignedIn'),
|
isSignedIn: Ember.computed.bool('user.isSignedIn'),
|
||||||
|
hideNav: Ember.computed.match('currentPath', /(signin|signup|forgotten|reset)/),
|
||||||
|
|
||||||
actions: {
|
actions: {
|
||||||
toggleMenu: function () {
|
toggleMenu: function () {
|
||||||
|
@ -1,7 +1,47 @@
|
|||||||
|
import ajax from 'ghost/utils/ajax';
|
||||||
import styleBody from 'ghost/mixins/style-body';
|
import styleBody from 'ghost/mixins/style-body';
|
||||||
|
|
||||||
var SignupRoute = Ember.Route.extend(styleBody, {
|
var SignupRoute = Ember.Route.extend(styleBody, {
|
||||||
classNames: ['ghost-signup']
|
classNames: ['ghost-signup'],
|
||||||
|
|
||||||
|
name: null,
|
||||||
|
email: null,
|
||||||
|
password: null,
|
||||||
|
|
||||||
|
actions: {
|
||||||
|
signup: function () {
|
||||||
|
var self = this,
|
||||||
|
controller = this.get('controller'),
|
||||||
|
data = controller.getProperties('name', 'email', 'password');
|
||||||
|
|
||||||
|
// TODO: Validate data
|
||||||
|
|
||||||
|
if (data.name && data.email && data.password) {
|
||||||
|
ajax({
|
||||||
|
url: '/ghost/signup/',
|
||||||
|
type: 'POST',
|
||||||
|
headers: {
|
||||||
|
'X-CSRF-Token': this.get('csrf')
|
||||||
|
},
|
||||||
|
data: data
|
||||||
|
}).then(function (resp) {
|
||||||
|
if (resp && resp.userData) {
|
||||||
|
self.send('signedIn', resp.userData);
|
||||||
|
|
||||||
|
self.notifications.clear();
|
||||||
|
|
||||||
|
self.transitionTo('posts');
|
||||||
|
} else {
|
||||||
|
self.transitionTo('signin');
|
||||||
|
}
|
||||||
|
}, function (resp) {
|
||||||
|
self.notifications.showAPIError(resp);
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
this.notifications.showError('Must provide name, email and password');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
export default SignupRoute;
|
export default SignupRoute;
|
||||||
|
@ -10,7 +10,11 @@
|
|||||||
|
|
||||||
<li id="usermenu" class="usermenu subnav">
|
<li id="usermenu" class="usermenu subnav">
|
||||||
<a href="javascript:void(0);" {{action 'toggleMenu'}} class="dropdown">
|
<a href="javascript:void(0);" {{action 'toggleMenu'}} class="dropdown">
|
||||||
|
{{#if user.image}}
|
||||||
<img class="avatar" {{bind-attr src="user.image"}} alt="Avatar" />
|
<img class="avatar" {{bind-attr src="user.image"}} alt="Avatar" />
|
||||||
|
{{else}}
|
||||||
|
<img class="avatar" src="/shared/img/user-image.png" alt="Avatar" />
|
||||||
|
{{/if}}
|
||||||
<span class="name">{{user.name}}</span>
|
<span class="name">{{user.name}}</span>
|
||||||
</a>
|
</a>
|
||||||
{{!-- @TODO: add functionality to allow for dropdown to work --}}
|
{{!-- @TODO: add functionality to allow for dropdown to work --}}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{{#if isSignedIn}}
|
{{#unless hideNav}}
|
||||||
{{partial "navbar"}}
|
{{partial "navbar"}}
|
||||||
{{/if}}
|
{{/unless}}
|
||||||
|
|
||||||
<main role="main" id="main">
|
<main role="main" id="main">
|
||||||
{{ghost-notifications}}
|
{{ghost-notifications}}
|
||||||
|
@ -1,14 +1,14 @@
|
|||||||
<section class="signup-box js-signup-box fade-in">
|
<section class="signup-box js-signup-box fade-in">
|
||||||
<form id="signup" class="signup-form" method="post" novalidate="novalidate">
|
<form id="signup" class="signup-form" method="post" novalidate="novalidate">
|
||||||
<div class="name-wrap">
|
<div class="name-wrap">
|
||||||
<input class="name" type="text" placeholder="Full Name" name="name" autofocus autocorrect="off" />
|
{{input class="name" type="text" placeholder="Full Name" name="name" autofocus="autofocus" autocorrect="off" value=name }}
|
||||||
</div>
|
</div>
|
||||||
<div class="email-wrap">
|
<div class="email-wrap">
|
||||||
<input class="email" type="email" placeholder="Email Address" name="email" autocapitalize="off" autocorrect="off" />
|
{{input class="email" type="email" placeholder="Email Address" name="email" autocapitalize="off" autocorrect="off" value=email }}
|
||||||
</div>
|
</div>
|
||||||
<div class="password-wrap">
|
<div class="password-wrap">
|
||||||
<input class="password" type="password" placeholder="Password" name="password" />
|
{{input class="password" type="password" placeholder="Password" name="password" value=password }}
|
||||||
</div>
|
</div>
|
||||||
<button class="button-save" type="submit">Sign Up</button>
|
<button class="button-save" type="submit" {{action "signup"}}>Sign Up</button>
|
||||||
</form>
|
</form>
|
||||||
</section>
|
</section>
|
||||||
|
@ -79,6 +79,11 @@ var middleware = {
|
|||||||
}
|
}
|
||||||
redirect = '?r=' + encodeURIComponent(reqPath);
|
redirect = '?r=' + encodeURIComponent(reqPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (subPath.indexOf('/ember') > -1) {
|
||||||
|
return res.redirect(config().paths.subdir + '/ghost/ember/signin');
|
||||||
|
}
|
||||||
|
|
||||||
return res.redirect(config().paths.subdir + '/ghost/signin/' + redirect);
|
return res.redirect(config().paths.subdir + '/ghost/signin/' + redirect);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user