summaryrefslogtreecommitdiffstats
path: root/web/react/components/email_verify.jsx
blob: ef1a62130253310bd4e6a2a8d5add8bc7aab4388 (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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
// Copyright (c) 2015 Mattermost, Inc. All Rights Reserved.
// See License.txt for license information.

import {FormattedMessage, FormattedHTMLMessage} from 'mm-intl';

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

        this.handleResend = this.handleResend.bind(this);

        this.state = {};
    }
    handleResend() {
        const newAddress = window.location.href.replace('&resend_success=true', '');
        window.location.href = newAddress + '&resend=true';
    }
    render() {
        var title = '';
        var body = '';
        var resend = '';
        var resendConfirm = '';
        if (this.props.isVerified === 'true') {
            title = (
                <FormattedMessage
                    id='email_verify.verified'
                    defaultMessage='{siteName} Email Verified'
                    values={{
                        siteName: global.window.mm_config.SiteName
                    }}
                />
            );
            body = (
                <FormattedHTMLMessage
                    id='email_verify.verifiedBody'
                    defaultMessage='<p>Your email has been verified! Click <a href={url}>here</a> to log in.</p>'
                    values={{
                        url: this.props.teamURL + '?email=' + this.props.userEmail
                    }}
                />
            );
        } else {
            title = (
                <FormattedMessage
                    id='email_verify.almost'
                    defaultMessage='{siteName}: You are almost done'
                    values={{
                        siteName: global.window.mm_config.SiteName
                    }}
                />
            );
            body = (
                <p>
                    <FormattedMessage
                        id='email_verify.notVerifiedBody'
                        defaultMessage='Please verify your email address. Check your inbox for an email.'
                    />
                </p>
            );
            resend = (
                <button
                    onClick={this.handleResend}
                    className='btn btn-primary'
                >
                    <FormattedMessage
                        id='email_verify.resend'
                        defaultMessage='Resend Email'
                    />
                </button>
            );
            if (this.props.resendSuccess) {
                resendConfirm = (
                    <div><br /><p className='alert alert-success'><i className='fa fa-check'></i>
                        <FormattedMessage
                            id='email_verify.sent'
                            defaultMessage=' Verification email sent.'
                        />
                    </p></div>);
            }
        }

        return (
            <div className='col-sm-12'>
                <div className='signup-team__container'>
                    <h3>{title}</h3>
                    <div>
                        {body}
                        {resend}
                        {resendConfirm}
                    </div>
                </div>
            </div>
        );
    }
}

EmailVerify.defaultProps = {
    isVerified: 'false',
    teamURL: '',
    userEmail: '',
    resendSuccess: 'false'
};
EmailVerify.propTypes = {
    isVerified: React.PropTypes.string,
    teamURL: React.PropTypes.string,
    userEmail: React.PropTypes.string,
    resendSuccess: React.PropTypes.string
};