From 0f1108b14eb641c60a73c8b621745e499fb8b4f5 Mon Sep 17 00:00:00 2001 From: ddejongh Date: Thu, 11 Jun 2015 17:22:11 +0200 Subject: [PATCH] form password + signup --- js/app.js | 2 +- .../ascribe_forms/form_password_reset.js | 51 ++++++++++++ .../form_password_reset_request.js | 41 ++++++++++ js/components/ascribe_forms/form_signup.js | 80 +++++++++++++++++++ js/constants/api_urls.js | 5 +- 5 files changed, 177 insertions(+), 2 deletions(-) create mode 100644 js/components/ascribe_forms/form_password_reset.js create mode 100644 js/components/ascribe_forms/form_password_reset_request.js create mode 100644 js/components/ascribe_forms/form_signup.js diff --git a/js/app.js b/js/app.js index 88809c50..2483fea9 100644 --- a/js/app.js +++ b/js/app.js @@ -23,7 +23,7 @@ fetch.defaults({ urlMap: ApiUrls, http: { headers: headers, - credentials: 'include' + credentials: 'cors' }, fatalErrorHandler: (err) => { console.log(err); diff --git a/js/components/ascribe_forms/form_password_reset.js b/js/components/ascribe_forms/form_password_reset.js new file mode 100644 index 00000000..8c2e4d61 --- /dev/null +++ b/js/components/ascribe_forms/form_password_reset.js @@ -0,0 +1,51 @@ +'use strict'; + +import React from 'react'; + +import apiUrls from '../../constants/api_urls'; +import FormMixin from '../../mixins/form_mixin'; +import InputText from './input_text'; +import ButtonSubmitOrClose from '../ascribe_buttons/button_submit_close'; + +let PasswordResetForm = React.createClass({ + mixins: [FormMixin], + + url() { + return apiUrls.users_password_reset; + }, + + getFormData() { + return { + email: this.props.email, + token: this.props.token, + password: this.refs.password.state.value, + password_confirm: this.refs.password_confirm.state.value + }; + }, + + renderForm() { + return ( +
+
Reset the password for {this.props.email}:
+ + + + + ); + } +}); + +export default PasswordResetForm; \ No newline at end of file diff --git a/js/components/ascribe_forms/form_password_reset_request.js b/js/components/ascribe_forms/form_password_reset_request.js new file mode 100644 index 00000000..f61e8b05 --- /dev/null +++ b/js/components/ascribe_forms/form_password_reset_request.js @@ -0,0 +1,41 @@ +'use strict'; + +import React from 'react'; + +import apiUrls from '../../constants/api_urls'; +import FormMixin from '../../mixins/form_mixin'; +import InputText from './input_text'; +import ButtonSubmitOrClose from '../ascribe_buttons/button_submit_close'; + +let PasswordResetRequestForm = React.createClass({ + mixins: [FormMixin], + + url() { + return apiUrls.users_password_reset_request; + }, + + getFormData() { + return { + email: this.refs.email.state.value + }; + }, + + renderForm() { + return ( +
+ + + + ); + } +}); + +export default PasswordResetRequestForm; \ No newline at end of file diff --git a/js/components/ascribe_forms/form_signup.js b/js/components/ascribe_forms/form_signup.js new file mode 100644 index 00000000..ba24b351 --- /dev/null +++ b/js/components/ascribe_forms/form_signup.js @@ -0,0 +1,80 @@ +'use strict'; + +import React from 'react'; + +import apiUrls from '../../constants/api_urls'; +import FormMixin from '../../mixins/form_mixin'; +import InputText from './input_text'; +import InputCheckbox from './input_checkbox'; +import ButtonSubmitOrClose from '../ascribe_buttons/button_submit_close'; + +let SignupForm = React.createClass({ + mixins: [FormMixin], + + url() { + return apiUrls.users_signup; + }, + + getFormData() { + return { + email: this.refs.email.state.value, + password: this.refs.password.state.value, + password_confirm: this.refs.password_confirm.state.value, + terms: this.refs.terms.state.value, + promo_code: this.refs.promo_code.state.value + }; + }, + + renderForm() { + return ( +
+ + + + + +
+ Your password must be at least 10 characters. + This password is securing your digital property like a bank account. + Store it in a safe place! +
+ + I agree to the  + Terms of Service + } + />) + + + + ); + } +}); + +export default SignupForm; \ No newline at end of file diff --git a/js/constants/api_urls.js b/js/constants/api_urls.js index 1bc835cd..9c00812d 100644 --- a/js/constants/api_urls.js +++ b/js/constants/api_urls.js @@ -23,7 +23,10 @@ let apiUrls = { 'ownership_loans_deny': AppConstants.apiEndpoint + 'ownership/loans/deny/', 'note_notes': AppConstants.apiEndpoint + 'note/notes/', 'user': AppConstants.apiEndpoint + 'users/', - 'users_login': AppConstants.apiEndpoint + 'users/login/' + 'users_login': AppConstants.apiEndpoint + 'users/login/', + 'users_signup': AppConstants.apiEndpoint + 'users/', + 'users_password_reset_request': AppConstants.apiEndpoint + 'users/request_reset_password/', + 'users_password_reset': AppConstants.apiEndpoint + 'users/reset_password/' }; export default apiUrls;