mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-11-30 21:40:39 +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({
|
||||
isSignedIn: Ember.computed.bool('user.isSignedIn'),
|
||||
hideNav: Ember.computed.match('currentPath', /(signin|signup|forgotten|reset)/),
|
||||
|
||||
actions: {
|
||||
toggleMenu: function () {
|
||||
|
@ -1,7 +1,47 @@
|
||||
import ajax from 'ghost/utils/ajax';
|
||||
import styleBody from 'ghost/mixins/style-body';
|
||||
|
||||
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;
|
||||
|
@ -10,7 +10,11 @@
|
||||
|
||||
<li id="usermenu" class="usermenu subnav">
|
||||
<a href="javascript:void(0);" {{action 'toggleMenu'}} class="dropdown">
|
||||
{{#if user.image}}
|
||||
<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>
|
||||
</a>
|
||||
{{!-- @TODO: add functionality to allow for dropdown to work --}}
|
||||
|
@ -1,6 +1,6 @@
|
||||
{{#if isSignedIn}}
|
||||
{{#unless hideNav}}
|
||||
{{partial "navbar"}}
|
||||
{{/if}}
|
||||
{{/unless}}
|
||||
|
||||
<main role="main" id="main">
|
||||
{{ghost-notifications}}
|
||||
|
@ -1,14 +1,14 @@
|
||||
<section class="signup-box js-signup-box fade-in">
|
||||
<form id="signup" class="signup-form" method="post" novalidate="novalidate">
|
||||
<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 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 class="password-wrap">
|
||||
<input class="password" type="password" placeholder="Password" name="password" />
|
||||
{{input class="password" type="password" placeholder="Password" name="password" value=password }}
|
||||
</div>
|
||||
<button class="button-save" type="submit">Sign Up</button>
|
||||
<button class="button-save" type="submit" {{action "signup"}}>Sign Up</button>
|
||||
</form>
|
||||
</section>
|
||||
|
@ -79,6 +79,11 @@ var middleware = {
|
||||
}
|
||||
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);
|
||||
});
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user