forgot password feature wip
This commit is contained in:
parent
33d0de6f0c
commit
df9cbf3ba7
|
|
@ -5,12 +5,12 @@ import { Link } from 'react-router-dom';
|
||||||
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
||||||
import envelope from '../../assets/img/illustrations/envelope.png';
|
import envelope from '../../assets/img/illustrations/envelope.png';
|
||||||
|
|
||||||
const ConfirmMailContent = ({ email, layout, titleTag: TitleTag }) => (
|
const ConfirmMailContent = ({ layout, titleTag: TitleTag }) => (
|
||||||
<Fragment>
|
<Fragment>
|
||||||
<img className="d-block mx-auto mb-4" src={envelope} alt="sent" width={70} />
|
<img className="d-block mx-auto mb-4" src={envelope} alt="sent" width={70} />
|
||||||
<TitleTag>Please check your email!</TitleTag>
|
<TitleTag>Please check your email!</TitleTag>
|
||||||
<p>
|
<p>
|
||||||
An email has been sent to <strong>{email}</strong>. Please click on the included link to reset your password.
|
An email has been sent to you. Please click on the included link to reset your password.
|
||||||
</p>
|
</p>
|
||||||
<Button tag={Link} color="primary" size="sm" className="mt-3" to={`/authentication/${layout}/login`}>
|
<Button tag={Link} color="primary" size="sm" className="mt-3" to={`/authentication/${layout}/login`}>
|
||||||
<FontAwesomeIcon icon="chevron-left" transform="shrink-4 down-1" className="mr-1" />
|
<FontAwesomeIcon icon="chevron-left" transform="shrink-4 down-1" className="mr-1" />
|
||||||
|
|
@ -20,7 +20,6 @@ const ConfirmMailContent = ({ email, layout, titleTag: TitleTag }) => (
|
||||||
);
|
);
|
||||||
|
|
||||||
ConfirmMailContent.propTypes = {
|
ConfirmMailContent.propTypes = {
|
||||||
email: PropTypes.string.isRequired,
|
|
||||||
layout: PropTypes.string,
|
layout: PropTypes.string,
|
||||||
titleTag: PropTypes.string
|
titleTag: PropTypes.string
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -4,23 +4,26 @@ import { Link } from 'react-router-dom';
|
||||||
import { toast } from 'react-toastify';
|
import { toast } from 'react-toastify';
|
||||||
import { Button, Form, FormGroup, Input } from 'reactstrap';
|
import { Button, Form, FormGroup, Input } from 'reactstrap';
|
||||||
import withRedirect from '../../hoc/withRedirect';
|
import withRedirect from '../../hoc/withRedirect';
|
||||||
import { resetPassword } from '../../helpers/rest';
|
import { requstResetForgotPassword } from '../../helpers/rest';
|
||||||
|
|
||||||
const ForgetPasswordForm = ({ setRedirect, setRedirectUrl, layout }) => {
|
const ForgetPasswordForm = ({ setRedirect, setRedirectUrl, layout }) => {
|
||||||
// State
|
// State
|
||||||
const [email, setEmail] = useState('');
|
const [email, setEmail] = useState('');
|
||||||
|
const [submitting, setSubmitting] = useState(false);
|
||||||
|
|
||||||
// Handler
|
// Handler
|
||||||
const handleSubmit = e => {
|
const handleSubmit = e => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
setSubmitting(true);
|
||||||
if (email) {
|
if (email) {
|
||||||
resetPassword(email)
|
requstResetForgotPassword(email)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
toast.success(`An email is sent to ${email} with password reset link`);
|
toast.success(`An email is sent to ${email} with password reset link`);
|
||||||
setRedirect(true);
|
setRedirect(true);
|
||||||
})
|
})
|
||||||
.catch(error => {
|
.catch(error => {})
|
||||||
toast.error(error.message);
|
.finally(() => {
|
||||||
|
setSubmitting(false);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
@ -38,17 +41,23 @@ const ForgetPasswordForm = ({ setRedirect, setRedirectUrl, layout }) => {
|
||||||
value={email}
|
value={email}
|
||||||
onChange={({ target }) => setEmail(target.value)}
|
onChange={({ target }) => setEmail(target.value)}
|
||||||
type="email"
|
type="email"
|
||||||
|
required
|
||||||
|
disabled={submitting}
|
||||||
/>
|
/>
|
||||||
</FormGroup>
|
</FormGroup>
|
||||||
<FormGroup>
|
<FormGroup>
|
||||||
<Button color="primary" block disabled={!email}>
|
<Button color="primary" block disabled={!email || submitting}>
|
||||||
Send reset link
|
Send reset link
|
||||||
</Button>
|
</Button>
|
||||||
</FormGroup>
|
</FormGroup>
|
||||||
<Link className="fs--1 text-600" to="#!">
|
{/* <Link className="fs--1 text-600" to="#!">
|
||||||
I can't recover my account using this page
|
I can't recover my account using this page
|
||||||
<span className="d-inline-block ml-1">→</span>
|
<span className="d-inline-block ml-1">→</span>
|
||||||
</Link>
|
</Link> */}
|
||||||
|
<a href="https://www.jamkazam.com/help_desk" target="_blank" rel="noopener noreferrer" className="fs--1 text-600">
|
||||||
|
I can't recover my account using this page
|
||||||
|
<span className="d-inline-block ml-1">→</span>
|
||||||
|
</a>
|
||||||
</Form>
|
</Form>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ import ConfirmMailContent from '../ConfirmMailContent';
|
||||||
|
|
||||||
const ConfirmMail = () => (
|
const ConfirmMail = () => (
|
||||||
<div className="text-center">
|
<div className="text-center">
|
||||||
<ConfirmMailContent email="xyz@abc.com" />
|
<ConfirmMailContent />
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,20 +6,22 @@ import Login from './Login';
|
||||||
// import Logout from './Logout';
|
// import Logout from './Logout';
|
||||||
// import Registration from './Registration';
|
// import Registration from './Registration';
|
||||||
import ForgetPassword from './ForgetPassword';
|
import ForgetPassword from './ForgetPassword';
|
||||||
// import PasswordReset from './PasswordReset';
|
import PasswordReset from './PasswordReset';
|
||||||
// import ConfirmMail from './ConfirmMail';
|
import ConfirmMail from './ConfirmMail';
|
||||||
// import LockScreen from './LockScreen';
|
// import LockScreen from './LockScreen';
|
||||||
|
|
||||||
const AuthBasicRoutes = ({ match: { url } }) => (
|
const AuthBasicRoutes = ({ match: { url } }) => (
|
||||||
<Switch>
|
<Switch>
|
||||||
<Route path={`${url}/login`} exact component={Login} />
|
<Route path={`${url}/login`} exact component={Login} />
|
||||||
<Route path={`${url}/forget-password`} exact component={ForgetPassword} />
|
<Route path={`${url}/forget-password`} exact component={ForgetPassword} />
|
||||||
|
<Route path={`${url}/confirm-mail`} exact component={ConfirmMail} />
|
||||||
|
<Route path={`${url}/reset_password_token`} exact component={PasswordReset} />
|
||||||
{/* <Route path={`${url}/start`} exact component={Start} />
|
{/* <Route path={`${url}/start`} exact component={Start} />
|
||||||
<Route path={`${url}/logout`} exact component={Logout} />
|
<Route path={`${url}/logout`} exact component={Logout} />
|
||||||
<Route path={`${url}/register`} exact component={Registration} />
|
<Route path={`${url}/register`} exact component={Registration} />
|
||||||
|
|
||||||
<Route path={`${url}/confirm-mail`} exact component={ConfirmMail} />
|
|
||||||
<Route path={`${url}/password-reset`} exact component={PasswordReset} />
|
|
||||||
<Route path={`${url}/lock-screen`} exact component={LockScreen} /> */}
|
<Route path={`${url}/lock-screen`} exact component={LockScreen} /> */}
|
||||||
|
|
||||||
{/*Redirect*/}
|
{/*Redirect*/}
|
||||||
|
|
|
||||||
|
|
@ -309,6 +309,28 @@ export const resetPassword = email => {
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const requstResetForgotPassword = email => {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
apiFetch(`/request_reset_forgot_password`, {
|
||||||
|
method: 'POST',
|
||||||
|
body: JSON.stringify({ email })
|
||||||
|
})
|
||||||
|
.then(response => resolve(response))
|
||||||
|
.catch(error => reject(error));
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
export const resetForgotPassword = (options = {}) => {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
apiFetch(`/reset_forgot_password`, {
|
||||||
|
method: 'POST',
|
||||||
|
body: JSON.stringify(options)
|
||||||
|
})
|
||||||
|
.then(response => resolve(response))
|
||||||
|
.catch(error => reject(error));
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
export const postUserAppInteraction = (userId, options) => {
|
export const postUserAppInteraction = (userId, options) => {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
apiFetch(`/users/${userId}/app_interactions`, {
|
apiFetch(`/users/${userId}/app_interactions`, {
|
||||||
|
|
|
||||||
|
|
@ -263,7 +263,6 @@
|
||||||
|
|
||||||
// called from sidebar when messages come in
|
// called from sidebar when messages come in
|
||||||
function messageReceived(payload) {
|
function messageReceived(payload) {
|
||||||
alert("messageReceived");
|
|
||||||
if(showing && otherId == payload.sender_id) {
|
if(showing && otherId == payload.sender_id) {
|
||||||
if(fullyInitialized) {
|
if(fullyInitialized) {
|
||||||
renderMessage(payload.msg, payload.sender_id, payload.sender_name, payload.created_at, true);
|
renderMessage(payload.msg, payload.sender_id, payload.sender_name, payload.created_at, true);
|
||||||
|
|
|
||||||
|
|
@ -18,13 +18,15 @@ class ApiSessionsController < ApiController
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
#reset_password_token is updated. inteanded for the react app (spa)
|
||||||
def request_reset_password
|
def request_reset_password
|
||||||
begin
|
begin
|
||||||
User.reset_password(params[:email], ApplicationHelper.base_uri(request))
|
User.reset_password(params[:email], APP_CONFIG.spa_origin)
|
||||||
|
render :json => {}, :status => 204
|
||||||
rescue JamRuby::JamArgumentError
|
rescue JamRuby::JamArgumentError
|
||||||
render :json => {:message => ValidationMessages::EMAIL_NOT_FOUND}, :status => 403
|
render :json => {:message => ValidationMessages::EMAIL_NOT_FOUND}, :status => 403
|
||||||
end
|
end
|
||||||
render :json => {}, :status => 204
|
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -16,9 +16,6 @@ Rails.application.routes.draw do
|
||||||
root to: 'users#home'
|
root to: 'users#home'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# signup, and signup completed, related pages
|
# signup, and signup completed, related pages
|
||||||
get '/signup', to: 'users#new'
|
get '/signup', to: 'users#new'
|
||||||
post '/signup', to: 'users#create'
|
post '/signup', to: 'users#create'
|
||||||
|
|
@ -31,8 +28,8 @@ Rails.application.routes.draw do
|
||||||
post '/signin', to: 'sessions#create'
|
post '/signin', to: 'sessions#create'
|
||||||
delete '/signout', to: 'sessions#destroy'
|
delete '/signout', to: 'sessions#destroy'
|
||||||
get '/passthrough', to: 'sessions#passthrough'
|
get '/passthrough', to: 'sessions#passthrough'
|
||||||
|
|
||||||
post '/request_reset_password', to: 'api_sessions#request_reset_password'
|
|
||||||
|
|
||||||
match '/redeem_giftcard', to: 'landings#redeem_giftcard', via: :get
|
match '/redeem_giftcard', to: 'landings#redeem_giftcard', via: :get
|
||||||
match '/account/activate/code_old', to: 'landings#account_activate', via: :get
|
match '/account/activate/code_old', to: 'landings#account_activate', via: :get
|
||||||
|
|
@ -412,6 +409,10 @@ Rails.application.routes.draw do
|
||||||
match '/users/:id/reset_password' => 'api_users#reset_password', :via => :post
|
match '/users/:id/reset_password' => 'api_users#reset_password', :via => :post
|
||||||
match '/users/:id/app_interactions' => 'api_users#post_app_interactions', :via => :post
|
match '/users/:id/app_interactions' => 'api_users#post_app_interactions', :via => :post
|
||||||
|
|
||||||
|
#reset forgot password (not logged in)
|
||||||
|
post '/request_reset_forgot_password', to: 'api_sessions#request_reset_password'
|
||||||
|
post '/reset_forgot_password', to: 'users#reset_forgot_password'
|
||||||
|
|
||||||
match '/reviews' => 'api_reviews#index', :via => :get
|
match '/reviews' => 'api_reviews#index', :via => :get
|
||||||
match '/reviews' => 'api_reviews#create', :via => :post
|
match '/reviews' => 'api_reviews#create', :via => :post
|
||||||
match '/reviews/:id' => 'api_reviews#update', :via => :post
|
match '/reviews/:id' => 'api_reviews#update', :via => :post
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue