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 envelope from '../../assets/img/illustrations/envelope.png';
|
||||
|
||||
const ConfirmMailContent = ({ email, layout, titleTag: TitleTag }) => (
|
||||
const ConfirmMailContent = ({ layout, titleTag: TitleTag }) => (
|
||||
<Fragment>
|
||||
<img className="d-block mx-auto mb-4" src={envelope} alt="sent" width={70} />
|
||||
<TitleTag>Please check your email!</TitleTag>
|
||||
<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>
|
||||
<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" />
|
||||
|
|
@ -20,7 +20,6 @@ const ConfirmMailContent = ({ email, layout, titleTag: TitleTag }) => (
|
|||
);
|
||||
|
||||
ConfirmMailContent.propTypes = {
|
||||
email: PropTypes.string.isRequired,
|
||||
layout: PropTypes.string,
|
||||
titleTag: PropTypes.string
|
||||
};
|
||||
|
|
|
|||
|
|
@ -4,23 +4,26 @@ import { Link } from 'react-router-dom';
|
|||
import { toast } from 'react-toastify';
|
||||
import { Button, Form, FormGroup, Input } from 'reactstrap';
|
||||
import withRedirect from '../../hoc/withRedirect';
|
||||
import { resetPassword } from '../../helpers/rest';
|
||||
import { requstResetForgotPassword } from '../../helpers/rest';
|
||||
|
||||
const ForgetPasswordForm = ({ setRedirect, setRedirectUrl, layout }) => {
|
||||
// State
|
||||
const [email, setEmail] = useState('');
|
||||
const [submitting, setSubmitting] = useState(false);
|
||||
|
||||
// Handler
|
||||
const handleSubmit = e => {
|
||||
e.preventDefault();
|
||||
setSubmitting(true);
|
||||
if (email) {
|
||||
resetPassword(email)
|
||||
requstResetForgotPassword(email)
|
||||
.then(() => {
|
||||
toast.success(`An email is sent to ${email} with password reset link`);
|
||||
setRedirect(true);
|
||||
})
|
||||
.catch(error => {
|
||||
toast.error(error.message);
|
||||
.catch(error => {})
|
||||
.finally(() => {
|
||||
setSubmitting(false);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
|
@ -38,17 +41,23 @@ const ForgetPasswordForm = ({ setRedirect, setRedirectUrl, layout }) => {
|
|||
value={email}
|
||||
onChange={({ target }) => setEmail(target.value)}
|
||||
type="email"
|
||||
required
|
||||
disabled={submitting}
|
||||
/>
|
||||
</FormGroup>
|
||||
<FormGroup>
|
||||
<Button color="primary" block disabled={!email}>
|
||||
<Button color="primary" block disabled={!email || submitting}>
|
||||
Send reset link
|
||||
</Button>
|
||||
</FormGroup>
|
||||
<Link className="fs--1 text-600" to="#!">
|
||||
{/* <Link className="fs--1 text-600" to="#!">
|
||||
I can't recover my account using this page
|
||||
<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>
|
||||
);
|
||||
};
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ import ConfirmMailContent from '../ConfirmMailContent';
|
|||
|
||||
const ConfirmMail = () => (
|
||||
<div className="text-center">
|
||||
<ConfirmMailContent email="xyz@abc.com" />
|
||||
<ConfirmMailContent />
|
||||
</div>
|
||||
);
|
||||
|
||||
|
|
|
|||
|
|
@ -6,20 +6,22 @@ import Login from './Login';
|
|||
// import Logout from './Logout';
|
||||
// import Registration from './Registration';
|
||||
import ForgetPassword from './ForgetPassword';
|
||||
// import PasswordReset from './PasswordReset';
|
||||
// import ConfirmMail from './ConfirmMail';
|
||||
import PasswordReset from './PasswordReset';
|
||||
import ConfirmMail from './ConfirmMail';
|
||||
// import LockScreen from './LockScreen';
|
||||
|
||||
const AuthBasicRoutes = ({ match: { url } }) => (
|
||||
<Switch>
|
||||
<Route path={`${url}/login`} exact component={Login} />
|
||||
<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}/logout`} exact component={Logout} />
|
||||
<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} /> */}
|
||||
|
||||
{/*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) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
apiFetch(`/users/${userId}/app_interactions`, {
|
||||
|
|
|
|||
|
|
@ -263,7 +263,6 @@
|
|||
|
||||
// called from sidebar when messages come in
|
||||
function messageReceived(payload) {
|
||||
alert("messageReceived");
|
||||
if(showing && otherId == payload.sender_id) {
|
||||
if(fullyInitialized) {
|
||||
renderMessage(payload.msg, payload.sender_id, payload.sender_name, payload.created_at, true);
|
||||
|
|
|
|||
|
|
@ -18,13 +18,15 @@ class ApiSessionsController < ApiController
|
|||
end
|
||||
end
|
||||
|
||||
#reset_password_token is updated. inteanded for the react app (spa)
|
||||
def request_reset_password
|
||||
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
|
||||
render :json => {:message => ValidationMessages::EMAIL_NOT_FOUND}, :status => 403
|
||||
end
|
||||
render :json => {}, :status => 204
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
|||
|
|
@ -16,9 +16,6 @@ Rails.application.routes.draw do
|
|||
root to: 'users#home'
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
# signup, and signup completed, related pages
|
||||
get '/signup', to: 'users#new'
|
||||
post '/signup', to: 'users#create'
|
||||
|
|
@ -31,8 +28,8 @@ Rails.application.routes.draw do
|
|||
post '/signin', to: 'sessions#create'
|
||||
delete '/signout', to: 'sessions#destroy'
|
||||
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 '/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/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#create', :via => :post
|
||||
match '/reviews/:id' => 'api_reviews#update', :via => :post
|
||||
|
|
|
|||
Loading…
Reference in New Issue