Blame view

imports/server/pages/verifyEmail.js 3.42 KB
b7054c9b2   Deepak   added specific or...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
  import React                              from 'react';
  import _                                  from 'lodash';
  import { Users }                          from '/imports/collections/users/index';
  
  
  
  
  const finishWithMessage = (res, message, redirect = "/") => {
  
    const output = `
  <html>
  <head>
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/simple-line-icons/2.4.1/css/simple-line-icons.css">
  <!-- Latest compiled and minified CSS -->
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
  <style type="text/css">
bea06ff0b   Deepak   Fixed teachers view
17

b7054c9b2   Deepak   added specific or...
18
  .congo-wrap .header {
bea06ff0b   Deepak   Fixed teachers view
19
20
21
22
23
24
25
26
      background: white;
      height: 50px;
  }
  
  .brand-style
  {
    font-family: 'Ubuntu', sans-serif !important;
    color:#00b395;
b7054c9b2   Deepak   added specific or...
27
  }
bea06ff0b   Deepak   Fixed teachers view
28

b7054c9b2   Deepak   added specific or...
29
30
  .congo-wrap .header .container {
      width: 100%;
b7054c9b2   Deepak   added specific or...
31
32
  }
  .congo-wrap{
bea06ff0b   Deepak   Fixed teachers view
33
      background:#00b395;
b7054c9b2   Deepak   added specific or...
34
35
36
      height:100%;
  }
  .widgetbox-congrats {
bea06ff0b   Deepak   Fixed teachers view
37
38
39
40
41
42
43
44
45
46
47
48
49
    margin: 20px auto;
    width: 400px;
    height: auto;
    padding: 20px;
    -webkit-border-radius: 8px/7px;
    -moz-border-radius: 8px/7px;
    border-radius: 8px/7px;
    background-color: white;
    -webkit-box-shadow: 1px 2px 5px rgba(0,0,0,.31);
    -moz-box-shadow: 1px 2px 5px rgba(0,0,0,.31);
    box-shadow: 1px 2px 5px rgba(0,0,0,.31);
    border: solid 1px #cbc9c9;
    font-family: 'Ubuntu', sans-serif;
b7054c9b2   Deepak   added specific or...
50
51
52
53
54
55
  }
  
  body {
      margin: 0;
      padding: 0;
  }
b7054c9b2   Deepak   added specific or...
56
57
  
  .text-blue {
bea06ff0b   Deepak   Fixed teachers view
58
      color: #00b395;
b7054c9b2   Deepak   added specific or...
59
60
61
62
63
  }
  
  .widgetbox-congrats .congo-msg h4 {
      margin: 8px 0;
      font-size: 24px;
bea06ff0b   Deepak   Fixed teachers view
64
      text-align:center;
b7054c9b2   Deepak   added specific or...
65
66
67
  }
  
  .widgetbox-congrats .congo-msg .icon {
bea06ff0b   Deepak   Fixed teachers view
68
     color: #00b395;
b7054c9b2   Deepak   added specific or...
69
      font-size: 90px;
bea06ff0b   Deepak   Fixed teachers view
70
71
72
      display: inline-block;
      width: 100%;
      text-align: center;
b7054c9b2   Deepak   added specific or...
73
  }
bea06ff0b   Deepak   Fixed teachers view
74
75
76
77
78
  p
  {
    display: inline-block;
    width: 100%;
    text-align: center;
b7054c9b2   Deepak   added specific or...
79
80
81
  }
  
  .widgetbox-congrats .widgetbox-footer .btn {
bea06ff0b   Deepak   Fixed teachers view
82
      background: #00b395;
b7054c9b2   Deepak   added specific or...
83
      color: #fff;
b7054c9b2   Deepak   added specific or...
84
      text-transform: uppercase;
bea06ff0b   Deepak   Fixed teachers view
85
86
87
88
      display: inline-block;
      width: 100%;
      text-align: center;
      font-family: 'Ubuntu', sans-serif;s
b7054c9b2   Deepak   added specific or...
89
90
91
92
93
94
95
96
97
  }
  </style>
  
  </head>
  
  <body>
  <div class="congo-wrap">
  <div class="header">
      <div class="container">
bea06ff0b   Deepak   Fixed teachers view
98
            <span class="brand-style">YOUNGDESK</span>
b7054c9b2   Deepak   added specific or...
99
100
101
102
103
104
105
106
107
108
109
110
      </div>
  </div>
      <div class="container">
          <div class="widgetbox-congrats">
              <div class="congo-msg">
                  <div class="text-blue">
                      <i class="icon icon-simple icon-check"></i>
                      <h4>Congrats!</h4>
                  </div>
                  <p> ${message}</p>
              </div>
              <div class="widgetbox-footer">
bea06ff0b   Deepak   Fixed teachers view
111
                  <a href="${redirect}" class="btn btn-md btn-prmary">Continue</a>
b7054c9b2   Deepak   added specific or...
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
              </div>
  
          </div>
      </div>
  </div>
  
  </html>
    `;
  
    res.writeHead(200, {
      'Content-Length': output.length,
      'Content-Type': 'text/html',
    });
    res.end(output);
  };
b7054c9b2   Deepak   added specific or...
127
128
129
130
131
132
133
134
135
136
137
138
139
140
  Picker.route('/back/verifyEmail/:token', function(params, req, res, next) {
  
    const user = Users.findOne({'services.email.verificationTokens.token': params.token});
    if(!user) return finishWithMessage(res, 'Invalid or outdated token.');
  
    const token = _.find(user.services.email.verificationTokens, x => x.token === params.token);
    if(new Date().getTime() - token.when.getTime() > 2 * 24 * 60 * 60 * 1000) return finishWithMessage(res, 'Invalid or outdated token.');
  
    finishWithMessage(res, 'Email has been verified.',"/");
    const idx = _.findIndex(user.emails, x => x.address === token.address);
  
    Users.update({_id: user._id}, {$set: {
      [`emails.${idx}.verified`]: true,
    }});
b7054c9b2   Deepak   added specific or...
141
  });