source: trunk/www/verify_device.jsp @ 7451

Last change on this file since 7451 was 7451, checked in by Nicklas Nordborg, 5 years ago

Fixes #2097: Implement support for device verification

Some minor changes in the email message and in the text in the browser. Seems to work ok.

File size: 4.0 KB
Line 
1<%-- $Id $
2  ------------------------------------------------------------------
3  Copyright (C) 2017 Nicklas Nordborg
4
5  This file is part of BASE - BioArray Software Environment.
6  Available at http://base.thep.lu.se/
7
8  BASE is free software; you can redistribute it and/or
9  modify it under the terms of the GNU General Public License
10  as published by the Free Software Foundation; either version 3
11  of the License, or (at your option) any later version.
12
13  BASE is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  GNU General Public License for more details.
17
18  You should have received a copy of the GNU General Public License
19  along with BASE. If not, see <http://www.gnu.org/licenses/>.
20  ------------------------------------------------------------------
21
22  @author Nicklas
23--%>
24<%@ page pageEncoding="UTF-8" session="false"
25  import="net.sf.basedb.core.Application"
26  import="net.sf.basedb.core.SessionControl"
27  import="net.sf.basedb.core.SessionControl.UnverifiedDeviceInfo"
28  import="net.sf.basedb.core.DbControl"
29  import="net.sf.basedb.clients.web.Base"
30  import="net.sf.basedb.clients.web.util.HTML"
31  import="net.sf.basedb.util.Values"
32  import="java.util.Date"
33%>
34<%@ taglib prefix="base" uri="/WEB-INF/base.tld" %>
35<%
36final String root = request.getContextPath()+"/";
37final String deviceId = Values.getString(request.getParameter("deviceId"), "");
38final SessionControl sc = Base.getSessionControl(pageContext, true);
39final UnverifiedDeviceInfo ui = sc.getUnverifiedDeviceInfo();
40final String ID = sc.getId();
41final DbControl dc = sc.newDbControl();
42
43try
44{
45  %>
46  <base:page type="default">
47  <base:head styles="login.css" scripts="~verify_device.js" />
48  <base:body style="padding-top: 5em;">
49    <form name="verification" action="login.jsp" method="post">
50    <input type="hidden" name="cmd" value="VerifyDevice">
51    <input type="hidden" name="ID" value="<%=ID%>">
52    <input type="hidden" name="useAutoStartPage" value="1">
53    <input type="hidden" name="deviceToken" value="<%=HTML.encodeTags(ui.getDeviceToken())%>">
54   
55    <table style="margin: auto; width: 700px;">
56    <tr>
57    <td>
58      <div class="messagecontainer help" id="login-help" style="text-align: center; padding: 1em;">
59        <b style="font-size: 125%;">This is the first time you are logging in from this device</b>
60        <div style="margin-top: 1em;">
61          A verification code has been sent to your registered email address:
62          <div style="margin: 0.5em; font-weight: bold;">
63            <%=HTML.encodeTags(ui.getUserName())%> &lt;<%=HTML.encodeTags(ui.getUserEmail())%>&gt;
64          </div>
65          Please enter the verification code in the form below to complete the login.<br>
66          The code can only be used once.
67        </div>
68      </div>
69     
70      <table style="width: 100%; margin-top: 1em; border-collapse: separate;">
71      <tr>
72        <td class="base-logo"><img src="images/baselogo.png" alt="BASE logo"></td>
73        <td style="width: 515px;">
74          <div id="loginform">
75          <table style="width: 100%;">
76            <tr id="password-row">
77              <th class="bg-filled-100">Verification code</th>
78              <td><input class="text auto-init" data-auto-init="focus" 
79                  name="verificationCode" id="verificationCode"
80                  type="text" autocomplete="off"
81                  maxlength="80" tabindex="0">
82              </td>
83            </tr>
84            <tr>
85              <th class="bg-filled-100">Remember this device</th>
86              <td>
87                <input type="checkbox" name="rememberDevice" id="rememberDevice" 
88                  <%=ui.getDefaultRememberDevice() ? "checked" :"" %> 
89                  style="width: auto;">
90              </td>
91              <td>
92                <base:button 
93                  id="btnVerify"
94                  image="login.png" title="Continue" 
95                />
96              </td>
97            </tr>
98            <tr><th class="bg-filled-100 subprompt">&nbsp;</th></tr>
99            </table>
100          </div>
101        </td>
102      </tr>
103      </table>
104
105    </form>
106  </base:body>
107  </base:page>
108  <%
109}
110finally
111{
112  if (dc != null) dc.close();
113}
114%>
115
Note: See TracBrowser for help on using the repository browser.