remove second request to create user
This commit is contained in:
parent
c90245dce6
commit
13fe7ab7d5
|
@ -6,6 +6,10 @@ Accept donations in Discourse! Integrates with [Stripe](https://stripe.com).
|
|||
|
||||
Note: Stripe requires HTTPS.
|
||||
|
||||
## Creating new user accounts
|
||||
|
||||
This is an experimental feature. A user can create a new account if there is a donation.
|
||||
|
||||
## Installation
|
||||
|
||||
* Follow the install instructions here: https://meta.discourse.org/t/install-a-plugin/19157
|
||||
|
@ -30,6 +34,5 @@ Visit `/admin/customize/site_texts` and search for 'discourse_donations'. You'll
|
|||
|
||||
## TODO
|
||||
|
||||
* Donate when creating account
|
||||
* Handle custom fields
|
||||
* Handle fails from stripe
|
||||
|
|
|
@ -48,26 +48,6 @@ export default Ember.Component.extend({
|
|||
this.set('result', this.get('result').concat(messages));
|
||||
},
|
||||
|
||||
createUser() {
|
||||
let self = this;
|
||||
ajax('/users/hp', { method: 'get' }).then(data => {
|
||||
let params = {
|
||||
email: self.get('email'),
|
||||
username: self.get('username'),
|
||||
name: self.get('name'),
|
||||
password: self.get('password'),
|
||||
password_confirmation: data.value,
|
||||
challenge: data.challenge.split('').reverse().join(''),
|
||||
};
|
||||
|
||||
ajax('/users', { data: params, method: 'post' }).then(data => {
|
||||
self.setSuccess();
|
||||
self.concatMessages(data.messages);
|
||||
self.endTranscation();
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
actions: {
|
||||
submitStripeCard() {
|
||||
let self = this;
|
||||
|
@ -93,25 +73,9 @@ export default Ember.Component.extend({
|
|||
if(!self.get('paymentSuccess')) {
|
||||
ajax('/charges', { data: params, method: 'post' }).then(data => {
|
||||
self.concatMessages(data.messages);
|
||||
|
||||
if(!this.get('create_accounts')) {
|
||||
if(data.status == 'succeeded') { this.setSuccess() };
|
||||
self.endTranscation();
|
||||
}
|
||||
else {
|
||||
if(data.status == 'succeeded') {
|
||||
this.createUser();
|
||||
}
|
||||
else {
|
||||
self.endTranscation();
|
||||
}
|
||||
}
|
||||
self.endTranscation();
|
||||
});
|
||||
}
|
||||
else if (this.get('create_accounts')) {
|
||||
self.set('result', []);
|
||||
self.createUser();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue