summaryrefslogtreecommitdiffstats
path: root/webapp/components/do_verify_email.jsx
blob: e0ac3218edcc37cfc755ffcb5be697862108ea20 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
// Copyright (c) 2016 Mattermost, Inc. All Rights Reserved.
// See License.txt for license information.

import {FormattedMessage} from 'react-intl';
import Client from 'client/web_client.jsx';
import LoadingScreen from './loading_screen.jsx';

import {browserHistory, Link} from 'react-router/es6';

import React from 'react';

export default class DoVerifyEmail extends React.Component {
    constructor(props) {
        super(props);

        this.state = {
            verifyStatus: 'pending',
            serverError: ''
        };
    }
    componentWillMount() {
        const uid = this.props.location.query.uid;
        const hid = this.props.location.query.hid;
        const email = this.props.location.query.email;

        Client.verifyEmail(
            uid,
            hid,
            () => {
                browserHistory.push('/login?extra=verified&email=' + email);
            },
            (err) => {
                this.setState({verifyStatus: 'failure', serverError: err.message});
            }
        );
    }
    render() {
        if (this.state.verifyStatus !== 'failure') {
            return (<LoadingScreen/>);
        }

        return (
            <div>
                <div className='signup-header'>
                    <Link to='/'>
                        <span className='fa fa-chevron-left'/>
                        <FormattedMessage
                            id='web.header.back'
                        />
                    </Link>
                </div>
                <div className='col-sm-12'>
                    <div className='signup-team__container'>
                        <h3>
                            <FormattedMessage
                                id='email_verify.almost'
                                defaultMessage='{siteName}: You are almost done'
                                values={{
                                    siteName: global.window.mm_config.SiteName
                                }}
                            />
                        </h3>
                        <div>
                            <p>
                                <FormattedMessage id='email_verify.verifyFailed'/>
                            </p>
                            <p className='alert alert-danger'>
                                <i className='fa fa-times'/>
                                {this.state.serverError}
                            </p>
                        </div>
                    </div>
                </div>
            </div>
        );
    }
}

DoVerifyEmail.defaultProps = {
};
DoVerifyEmail.propTypes = {
    location: React.PropTypes.object.isRequired
};