diff --git a/phoneblock/src/main/java/de/haumacher/phoneblock/app/EMailVerificationServlet.java b/phoneblock/src/main/java/de/haumacher/phoneblock/app/EMailVerificationServlet.java index 165122e3..7cacef07 100644 --- a/phoneblock/src/main/java/de/haumacher/phoneblock/app/EMailVerificationServlet.java +++ b/phoneblock/src/main/java/de/haumacher/phoneblock/app/EMailVerificationServlet.java @@ -18,16 +18,27 @@ import de.haumacher.phoneblock.db.DBService; import de.haumacher.phoneblock.mail.MailService; import de.haumacher.phoneblock.mail.MailServiceStarter; +import de.haumacher.phoneblock.util.ServletUtil; /** - * {@link HttpServlet} that is invoked from the signup.jsp form. + * {@link HttpServlet} that is invoked from the login.jsp form when requesting to login by e-mail. */ @WebServlet(urlPatterns = { - EMailVerificationServlet.VERIFY_WEB, + EMailVerificationServlet.LOGIN_WEB, }) public class EMailVerificationServlet extends HttpServlet { - public static final String VERIFY_WEB = "/verify-web"; + /** + * Request attribute holding the page to re-start login/signup. + */ + public static final String RESTART_PAGE_ATTR = "restartPage"; + + /** + * Request attribute set, if e-mail verification failed. + */ + public static final String VERIFY_ERROR_ATTR = "message"; + + public static final String LOGIN_WEB = "/login-web"; private static final Logger LOG = LoggerFactory.getLogger(EMailVerificationServlet.class); @@ -66,26 +77,30 @@ protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws S req.getSession().setAttribute("email", email); req.getSession().setAttribute("code", code); req.setAttribute("email", email); + req.setAttribute(RESTART_PAGE_ATTR, failurePage(req)); req.getRequestDispatcher(successPage(req)).forward(req, resp); } private void sendFailure(HttpServletRequest req, HttpServletResponse resp, String message) throws ServletException, IOException { - req.setAttribute("message", message); + req.setAttribute(VERIFY_ERROR_ATTR, message); req.getRequestDispatcher(failurePage(req)).forward(req, resp); } - private String failurePage(HttpServletRequest req) { + /** + * The page to redirect, if something went wrong. + */ + private static String failurePage(HttpServletRequest req) { switch (req.getServletPath()) { - case VERIFY_WEB: + case LOGIN_WEB: default: - return "/signup.jsp"; + return "/login.jsp"; } } private String successPage(HttpServletRequest req) { switch (req.getServletPath()) { - case VERIFY_WEB: + case LOGIN_WEB: default: return "/signup-code.jsp"; } diff --git a/phoneblock/src/main/java/de/haumacher/phoneblock/app/LoginServlet.java b/phoneblock/src/main/java/de/haumacher/phoneblock/app/LoginServlet.java index 74afa0a5..87e2d16b 100644 --- a/phoneblock/src/main/java/de/haumacher/phoneblock/app/LoginServlet.java +++ b/phoneblock/src/main/java/de/haumacher/phoneblock/app/LoginServlet.java @@ -27,6 +27,11 @@ @WebServlet(urlPatterns = LoginServlet.PATH) public class LoginServlet extends HttpServlet { + /** + * Request attribute set, if a login was not successful. + */ + public static final String LOGIN_ERROR_ATTR = "loginError"; + public static final String USER_NAME_PARAM = "userName"; public static final String PASSWORD_PARAM = "password"; @@ -96,6 +101,13 @@ protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws S LoginFilter.setAuthenticatedUser(req, authenticatedUser); + redirectToLocationAfterLogin(req, resp); + } + + /** + * Redirects the current request to its final destination. + */ + public static void redirectToLocationAfterLogin(HttpServletRequest req, HttpServletResponse resp) throws IOException { String location = location(req); if (location == null) { resp.sendRedirect(req.getContextPath() + SettingsServlet.PATH); @@ -120,7 +132,7 @@ public static void processRememberMe(HttpServletRequest req, HttpServletResponse * Redirects the client to the login page. */ public static void sendFailure(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { - req.setAttribute("error", "Anmeldung fehlgeschlagen."); + req.setAttribute(LOGIN_ERROR_ATTR, "Anmeldung fehlgeschlagen."); req.getRequestDispatcher("/login.jsp").forward(req, resp); } diff --git a/phoneblock/src/main/java/de/haumacher/phoneblock/app/RegistrationServlet.java b/phoneblock/src/main/java/de/haumacher/phoneblock/app/RegistrationServlet.java index 7b1382b8..33adb7ae 100644 --- a/phoneblock/src/main/java/de/haumacher/phoneblock/app/RegistrationServlet.java +++ b/phoneblock/src/main/java/de/haumacher/phoneblock/app/RegistrationServlet.java @@ -27,15 +27,15 @@ }) public class RegistrationServlet extends HttpServlet { + /** + * Request attribute set, if registration fails. + */ + public static final String REGISTER_ERROR_ATTR = "message"; + public static final String REGISTER_WEB = "/register-web"; private static final String PASSWORD_ATTR = "passwd"; - /** - * The authorization scope "email". - */ - public static final String IDENTIFIED_BY_EMAIL = "email"; - private static final Logger LOG = LoggerFactory.getLogger(RegistrationServlet.class); @Override @@ -57,26 +57,33 @@ protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws S String email = (String) req.getSession().getAttribute("email"); String login; - String passwd; try { + String passwd; + DB db = DBService.getInstance(); - String extId = email.trim().toLowerCase(); - login = db.getLogin(RegistrationServlet.IDENTIFIED_BY_EMAIL, extId); + login = db.getEmailLogin(email); if (login == null) { login = UUID.randomUUID().toString(); - passwd = db.createUser(IDENTIFIED_BY_EMAIL, extId, login, email); + + String displayName = DB.toDisplayName(email); + + passwd = db.createUser(login, displayName); db.setEmail(login, email); } else { - passwd = db.resetPassword(login); + // No longer known. + passwd = null; } + + String rememberValue = req.getParameter(LoginServlet.REMEMBER_PARAM); + LoginServlet.processRememberMe(req, resp, db, rememberValue, login); + + startSetup(req, resp, login, passwd); } catch (Exception ex) { LOG.error("Failed to create user: " + email, ex); sendError(req, resp, "Bei der Erstellung des Accounts ist ein Fehler aufgetreten: " + ex.getMessage()); return; } - - startSetup(req, resp, login, passwd); } /** @@ -85,13 +92,20 @@ protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws S public static void startSetup(HttpServletRequest req, HttpServletResponse resp, String login, String passwd) throws ServletException, IOException { LoginFilter.setAuthenticatedUser(req, login); - req.getSession().setAttribute(PASSWORD_ATTR, passwd); + if (passwd != null) { + req.getSession().setAttribute(PASSWORD_ATTR, passwd); + } String location = LoginServlet.location(req); if (location != null) { resp.sendRedirect(req.getContextPath() + location); } else { - resp.sendRedirect(req.getContextPath() + successPage(req)); + if (passwd == null) { + // Was already registered, no automatic password-reset. + resp.sendRedirect(req.getContextPath() + SettingsServlet.PATH); + } else { + resp.sendRedirect(req.getContextPath() + successPage(req)); + } } } @@ -104,7 +118,7 @@ private static String successPage(HttpServletRequest req) { } private void sendError(HttpServletRequest req, HttpServletResponse resp, String message) throws ServletException, IOException { - req.setAttribute("message", message); + req.setAttribute(REGISTER_ERROR_ATTR, message); req.getRequestDispatcher(errorPage(req)).forward(req, resp); } diff --git a/phoneblock/src/main/java/de/haumacher/phoneblock/app/ResetPasswordServlet.java b/phoneblock/src/main/java/de/haumacher/phoneblock/app/ResetPasswordServlet.java index 4b9afe41..da74c3d7 100644 --- a/phoneblock/src/main/java/de/haumacher/phoneblock/app/ResetPasswordServlet.java +++ b/phoneblock/src/main/java/de/haumacher/phoneblock/app/ResetPasswordServlet.java @@ -40,7 +40,7 @@ protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws S String password = DBService.getInstance().resetPassword(login); if (password == null) { req.setAttribute("message", "Nutzername nicht gefunden, bitte versuch Dich neu zu registrieren."); - req.getRequestDispatcher("/signup.jsp").forward(req, resp); + req.getRequestDispatcher("/login.jsp").forward(req, resp); return; } diff --git a/phoneblock/src/main/java/de/haumacher/phoneblock/app/api/VerificationServlet.java b/phoneblock/src/main/java/de/haumacher/phoneblock/app/api/VerificationServlet.java index 03d9eb96..bb85dc37 100644 --- a/phoneblock/src/main/java/de/haumacher/phoneblock/app/api/VerificationServlet.java +++ b/phoneblock/src/main/java/de/haumacher/phoneblock/app/api/VerificationServlet.java @@ -6,6 +6,7 @@ import java.io.IOException; import java.util.UUID; +import jakarta.mail.internet.AddressException; import jakarta.servlet.ServletException; import jakarta.servlet.annotation.WebServlet; import jakarta.servlet.http.HttpServlet; @@ -45,17 +46,22 @@ protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws S DB db = DBService.getInstance(); String email = sessionInfo.getEmail(); - String extId = email.trim().toLowerCase(); - String login = db.getLogin(RegistrationServlet.IDENTIFIED_BY_EMAIL, extId); + String login; String password; - if (login == null) { - login = UUID.randomUUID().toString(); - password = db.createUser(RegistrationServlet.IDENTIFIED_BY_EMAIL, extId, login, email); - } else { - password = db.resetPassword(login); + try { + login = db.getEmailLogin(email); + if (login == null) { + login = UUID.randomUUID().toString(); + password = db.createUser(login, email); + db.setEmail(login, email); + } else { + password = db.resetPassword(login); + } + } catch (AddressException e) { + ServletUtil.sendError(resp, "Invalid e-mail address."); + return; } - db.setEmail(login, email); ServletUtil.sendResult(req, resp, RegistrationResult.create().setSession(sessionInfo.getSession()).setLogin(login).setPassword(password)); } diff --git a/phoneblock/src/main/java/de/haumacher/phoneblock/app/oauth/OAuthLoginServlet.java b/phoneblock/src/main/java/de/haumacher/phoneblock/app/oauth/OAuthLoginServlet.java index a7463944..347e77e2 100644 --- a/phoneblock/src/main/java/de/haumacher/phoneblock/app/oauth/OAuthLoginServlet.java +++ b/phoneblock/src/main/java/de/haumacher/phoneblock/app/oauth/OAuthLoginServlet.java @@ -7,6 +7,7 @@ import java.util.Optional; import java.util.UUID; +import jakarta.mail.internet.AddressException; import jakarta.servlet.ServletException; import jakarta.servlet.annotation.WebServlet; import jakarta.servlet.http.HttpServlet; @@ -76,13 +77,31 @@ protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws Se displayName = null; } - String extId = userProfile.getId(); + String googleId = userProfile.getId(); Optional location = sessionStore.get(context, LoginServlet.LOCATION_ATTRIBUTE); DB db = DBService.getInstance(); - String login = db.getLogin(clientName, extId); + String login = db.getGoogleLogin(googleId); if (login == null) { + if (email != null && !email.isBlank()) { + try { + login = db.getEmailLogin(email); + if (login != null) { + // Link accounts. + db.setGoogleId(login, googleId, displayName); + } + } catch (AddressException e) { + LOG.warn("Reveived invalid e-mail address during Google login of {} login: {}", googleId, email); + + // Do not try again, see below. + email = null; + } + } + } + + if (login == null) { + // Create new account. login = UUID.randomUUID().toString(); if (displayName == null) { @@ -93,10 +112,14 @@ protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws Se } } - String passwd = db.createUser(clientName, extId, login, displayName); - db.setExtId(login, extId); + String passwd = db.createUser(login, displayName); + db.setGoogleId(login, googleId, null); if (email != null) { - db.setEmail(login, email); + try { + db.setEmail(login, email); + } catch (AddressException e) { + LOG.warn("Reveived invalid e-mail address during Google login of {} login: {}", googleId, email); + } } if (location.isEmpty()) { diff --git a/phoneblock/src/main/java/de/haumacher/phoneblock/carddav/resource/AddressBookCache.java b/phoneblock/src/main/java/de/haumacher/phoneblock/carddav/resource/AddressBookCache.java index a2c14f47..712c14ab 100644 --- a/phoneblock/src/main/java/de/haumacher/phoneblock/carddav/resource/AddressBookCache.java +++ b/phoneblock/src/main/java/de/haumacher/phoneblock/carddav/resource/AddressBookCache.java @@ -79,7 +79,7 @@ public AddressBookResource lookupAddressBook(String rootUrl, String serverRoot, try (SqlSession session = DBService.getInstance().openSession()) { Users users = session.getMapper(Users.class); - UserSettings settings = users.getSettings(principal); + UserSettings settings = users.getSettingsRaw(principal); int minVotes = settings.getMinVotes(); int maxLength = settings.getMaxLength(); diff --git a/phoneblock/src/main/java/de/haumacher/phoneblock/db/DB.java b/phoneblock/src/main/java/de/haumacher/phoneblock/db/DB.java index 5615c74b..8a8e1ca9 100644 --- a/phoneblock/src/main/java/de/haumacher/phoneblock/db/DB.java +++ b/phoneblock/src/main/java/de/haumacher/phoneblock/db/DB.java @@ -70,6 +70,8 @@ import de.haumacher.phoneblock.mail.MailService; import de.haumacher.phoneblock.mail.check.db.Domains; import de.haumacher.phoneblock.scheduler.SchedulerService; +import jakarta.mail.internet.AddressException; +import jakarta.mail.internet.InternetAddress; /** * The database abstraction layer. @@ -263,7 +265,7 @@ else if (!tableNames.contains("NUMBERS")) { Map searchesToday = new HashMap<>(); try (PreparedStatement stmt = connection.prepareStatement(""" - SELECT s.PHONE, s.TODAY FROM SEARCHES s WHERE s.TODAY > 0 + SELECT s.PHONE, s.COUNT - s.BACKUP FROM SEARCHES s WHERE s.COUNT - s.BACKUP > 0 """)) { try (ResultSet result = stmt.executeQuery()) { while (result.next()) { @@ -438,13 +440,13 @@ public String generateVerificationCode() { /** * Creates a new PhoneBlock user account. * @param clientName The authorization scope for the new user. - * @param extId The ID in the given authorization scope. + * @param googleId The ID for Google authentication. * @param login The user name (e.g. e-mail address) of the new account. * @return The randomly generated password for the account. */ - public String createUser(String clientName, String extId, String login, String displayName) { + public String createUser(String login, String displayName) { String passwd = createPassword(20); - addUser(clientName, extId, login, displayName, passwd); + addUser(login, displayName, passwd); return passwd; } @@ -653,21 +655,25 @@ public String createId(int length) { /** * Sets the user's e-mail address. */ - public void setEmail(String login, String email) { + public void setEmail(String login, String email) throws AddressException { try (SqlSession session = openSession()) { Users users = session.getMapper(Users.class); - users.setEmail(login, email); + users.setEmail(login, canonicalEMail(email)); session.commit(); } } /** * Sets the user's external ID in its OAuth authorization scope. + * @param displayName */ - public void setExtId(String login, String extId) { + public void setGoogleId(String login, String googleId, String displayName) { try (SqlSession session = openSession()) { Users users = session.getMapper(Users.class); - users.setExtId(login, extId); + users.setGoogleId(login, googleId); + if (displayName != null && !displayName.isBlank()) { + users.setDisplayName(login, displayName); + } session.commit(); } } @@ -1118,14 +1124,63 @@ public static Rating rating(NumberInfo n) { } private int getMinVotes(SqlSession session, String login) { - int minVotes = (login == null) ? MIN_VOTES : getSettings(session, login).getMinVotes(); + int minVotes = (login == null) ? MIN_VOTES : getUserSettingsRaw(session, login).getMinVotes(); return minVotes; } - private DBUserSettings getSettings(SqlSession session, String login) { + private DBUserSettings getUserSettingsRaw(SqlSession session, String login) { Users users = session.getMapper(Users.class); - DBUserSettings settings = users.getSettings(login); - return settings; + return users.getSettingsRaw(login); + } + + private DBUserSettings getUserSettings(Users users, String login) { + DBUserSettings result = users.getSettingsRaw(login); + + // For legacy compatibility (e-mail addresses as display name). + result.setDisplayName(DB.toDisplayName(result.getDisplayName())); + + return result; + } + + /** + * Guesses a display name from an e-mail address. + */ + public static String toDisplayName(String email) { + int atIndex = email.indexOf('@'); + if (atIndex > 0) { + email = email.substring(0, atIndex); + } + + StringBuilder result = new StringBuilder(); + boolean first = true; + for (String part : email.replace('.', ' ').replace('_', ' ').split("\\s+")) { + if (part.length() == 0) { + continue; + } + + if (first) { + first = false; + } else { + result.append(' '); + } + + boolean firstPart = true; + for (String subPart : part.split("-")) { + if (subPart.length() == 0) { + continue; + } + + if (firstPart) { + firstPart = false; + } else { + result.append('-'); + } + result.append(Character.toUpperCase(subPart.charAt(0))); + result.append(subPart.substring(1)); + } + } + + return result.toString(); } /** @@ -1311,10 +1366,10 @@ public void shutdown() { /** * Adds the given user with the given password. */ - public void addUser(String clientName, String extId, String login, String displayName, String passwd) { + public void addUser(String login, String displayName, String passwd) { try (SqlSession session = openSession()) { Users users = session.getMapper(Users.class); - users.addUser(login, clientName, extId, displayName, pwhash(passwd), System.currentTimeMillis()); + users.addUser(login, displayName, pwhash(passwd), System.currentTimeMillis()); session.commit(); } } @@ -1341,16 +1396,36 @@ public String resetPassword(String login) { } /** - * The user ID, or null, if the user with the given login does not yet exist. + * The local user ID, or null, if the user with the given login does not yet exist. + * + * @param googleId the user's ID in the Google OpenID provider. + */ + public String getGoogleLogin(String googleId) { + try (SqlSession session = openSession()) { + Users users = session.getMapper(Users.class); + + return users.getGoogleLogin(googleId); + } + } + + /** + * The local user ID, or null, if the user with the given login does not yet exist. + * + * @param email the user's e-mail address. */ - public String getLogin(String clientName, String extId) { + public String getEmailLogin(String email) throws AddressException { try (SqlSession session = openSession()) { Users users = session.getMapper(Users.class); - return users.getLogin(clientName, extId); + return users.getEmailLogin(canonicalEMail(email)); } } + private String canonicalEMail(String email) throws AddressException { + InternetAddress address = new InternetAddress(email); + return address.getAddress().strip().toLowerCase(); + } + /** * Sets the last access time for the given user to the given timestamp. * @@ -1368,7 +1443,7 @@ public void updateLastAccess(String login, long timestamp, String userAgent) { // This was the first access, send welcome message; MailService mailService = _mailService; if (mailService != null) { - DBUserSettings userSettings = users.getSettings(login); + DBUserSettings userSettings = getUserSettings(users, login); users.markWelcome(userSettings.getId()); session.commit(); @@ -1387,7 +1462,7 @@ public UserSettings getSettings(String login) { try (SqlSession session = openSession()) { Users users = session.getMapper(Users.class); - return users.getSettings(login); + return getUserSettings(users, login); } } diff --git a/phoneblock/src/main/java/de/haumacher/phoneblock/db/Users.java b/phoneblock/src/main/java/de/haumacher/phoneblock/db/Users.java index 96a6986f..e705f7dc 100644 --- a/phoneblock/src/main/java/de/haumacher/phoneblock/db/Users.java +++ b/phoneblock/src/main/java/de/haumacher/phoneblock/db/Users.java @@ -12,7 +12,6 @@ import org.apache.ibatis.annotations.Update; import de.haumacher.phoneblock.ab.DBAnswerbotInfo; -import de.haumacher.phoneblock.ab.proto.AnswerbotInfo; import de.haumacher.phoneblock.db.settings.AuthToken; /** @@ -20,9 +19,9 @@ */ public interface Users { - @Insert("insert into USERS (LOGIN, CLIENTNAME, EXTID, DISPLAYNAME, PWHASH, REGISTERED, MIN_VOTES, MAX_LENGTH) " + - "values (#{login}, #{clientName}, #{extId}, #{displayName}, #{pwhash}, #{registered}, 4, 2000)") - void addUser(String login, String clientName, String extId, String displayName, byte[] pwhash, long registered); + @Insert("insert into USERS (LOGIN, DISPLAYNAME, PWHASH, REGISTERED, MIN_VOTES, MAX_LENGTH) " + + "values (#{login}, #{displayName}, #{pwhash}, #{registered}, 4, 2000)") + void addUser(String login, String displayName, byte[] pwhash, long registered); @Update("update USERS set PWHASH=#{pwhash} where ID=#{userId}") void setPassword(long userId, byte[] pwhash); @@ -30,8 +29,11 @@ public interface Users { @Update("update USERS set EMAIL=#{email} where LOGIN=#{login}") void setEmail(String login, String email); - @Update("update USERS set EXTID=#{extId} where LOGIN=#{login}") - void setExtId(String login, String extId); + @Update("update USERS set GOOGLEID=#{googleId} where LOGIN=#{login}") + void setGoogleId(String login, String googleId); + + @Update("update USERS set DISPLAYNAME=#{displayName} where LOGIN=#{login}") + void setDisplayName(String login, String displayName); @Delete("delete from USERS where LOGIN=#{login}") void deleteUser(String login); @@ -131,13 +133,19 @@ insert into TOKENS ( Long getUserId(String login); /** - * Retrieves the user ID for the user with the given user name (e-mail). + * Retrieves the user ID for the user with the given Google ID. + */ + @Select("select LOGIN from USERS where GOOGLEID=#{googleId}") + String getGoogleLogin(String googleId); + + /** + * Retrieves the user ID for the user with the given e-mail. */ - @Select("select LOGIN from USERS where CLIENTNAME=#{clientName} and EXTID=#{extId}") - String getLogin(String clientName, String extId); + @Select("select LOGIN from USERS where EMAIL=#{email}") + String getEmailLogin(String email); @Select("select ID, LOGIN, DISPLAYNAME, EMAIL, MIN_VOTES, MAX_LENGTH, WILDCARDS, LASTACCESS from USERS where LOGIN=#{login}") - DBUserSettings getSettings(String login); + DBUserSettings getSettingsRaw(String login); @Select("select LOGIN from USERS where ID=#{userId}") String getUserName(long userId); diff --git a/phoneblock/src/main/java/de/haumacher/phoneblock/db/db-migration-03.sql b/phoneblock/src/main/java/de/haumacher/phoneblock/db/db-migration-03.sql new file mode 100644 index 00000000..67f7f432 --- /dev/null +++ b/phoneblock/src/main/java/de/haumacher/phoneblock/db/db-migration-03.sql @@ -0,0 +1,8 @@ +ALTER TABLE USERS ADD GOOGLEID CHARACTER VARYING(64); + +UPDATE USERS SET GOOGLEID = EXTID WHERE CLIENTNAME = 'Google2Client'; + +ALTER TABLE USERS ALTER COLUMN EXTID VARCHAR_IGNORECASE(64) NULL; +ALTER TABLE USERS ALTER COLUMN CLIENTNAME VARCHAR_IGNORECASE(64) NULL; + +UPDATE USERS SET EMAIL = LOWER(EMAIL); \ No newline at end of file diff --git a/phoneblock/src/main/java/de/haumacher/phoneblock/db/db-schema.sql b/phoneblock/src/main/java/de/haumacher/phoneblock/db/db-schema.sql index 1e67576f..450ecd20 100644 --- a/phoneblock/src/main/java/de/haumacher/phoneblock/db/db-schema.sql +++ b/phoneblock/src/main/java/de/haumacher/phoneblock/db/db-schema.sql @@ -140,8 +140,9 @@ CREATE TABLE USERS ( LOGIN CHARACTER VARYING(255) NOT NULL, PWHASH BINARY VARYING(128) NOT NULL, - CLIENTNAME CHARACTER VARYING(64) NOT NULL, - EXTID CHARACTER VARYING(255), + CLIENTNAME CHARACTER VARYING(64) NULL, + EXTID CHARACTER VARYING(64) NULL, + GOOGLEID CHARACTER VARYING(64) NULL, DISPLAYNAME CHARACTER VARYING(255) NOT NULL, EMAIL CHARACTER VARYING(255), @@ -158,8 +159,9 @@ CREATE TABLE USERS ( CONSTRAINT USERS_PK PRIMARY KEY (ID) ); -CREATE INDEX USERS_CLIENTNAME_IDX ON USERS (CLIENTNAME,EXTID); CREATE UNIQUE INDEX USERS_UN_INDEX_4 ON USERS (LOGIN); +CREATE INDEX USERS_EMAIL_INDEX ON USERS (EMAIL); +CREATE INDEX USERS_GOOGLEID_IDX ON USERS (GOOGLEID); CREATE TABLE PUBLIC.CONTRIBUTIONS ( ID BIGINT NOT NULL AUTO_INCREMENT, diff --git a/phoneblock/src/main/java/de/haumacher/phoneblock/mail/MailService.java b/phoneblock/src/main/java/de/haumacher/phoneblock/mail/MailService.java index c7412a49..87fe8216 100644 --- a/phoneblock/src/main/java/de/haumacher/phoneblock/mail/MailService.java +++ b/phoneblock/src/main/java/de/haumacher/phoneblock/mail/MailService.java @@ -21,6 +21,7 @@ import de.haumacher.phoneblock.app.Application; import de.haumacher.phoneblock.app.SettingsServlet; +import de.haumacher.phoneblock.db.DB; import de.haumacher.phoneblock.db.DBUserSettings; import de.haumacher.phoneblock.db.settings.AnswerBotSip; import de.haumacher.phoneblock.mail.check.EMailCheckService; @@ -104,10 +105,11 @@ public void sendActivationMail(String receiver, String code) LOG.info("Sending activation mail to '" + receiver + "'."); Map variables = new HashMap<>(); + variables.put("{name}", DB.toDisplayName(address.getAddress())); variables.put("{code}", code); variables.put("{image}", _appLogoSvg); - sendMail("PhoneBlock E-Mail Bestätigung", address, "mail-template", variables); + sendMail("PhoneBlock Anmelde-Code", address, "mail-template", variables); } public boolean sendHelpMail(DBUserSettings userSettings) { @@ -176,15 +178,8 @@ public void sendWelcomeMail(DBUserSettings userSettings) { } private Map buildVariables(DBUserSettings userSettings) { - String name = userSettings.getDisplayName(); - int atIndex = name.indexOf('@'); - if (atIndex > 0) { - name = name.substring(0, atIndex); - } - name = toUpperCaseStart(name); - Map variables = new HashMap<>(); - variables.put("{name}", name); + variables.put("{name}", userSettings.getDisplayName()); variables.put("{userName}", userSettings.getLogin()); variables.put("{lastAccess}", formatDateTime(userSettings.getLastAccess())); variables.put("{image}", _appLogoSvg); @@ -335,37 +330,4 @@ private Session getSession() throws AddressException { return _session; } - private static String toUpperCaseStart(String name) { - StringBuilder result = new StringBuilder(); - boolean first = true; - for (String part : name.replace('.', ' ').replace('_', ' ').split("\\s+")) { - if (part.length() == 0) { - continue; - } - - if (first) { - first = false; - } else { - result.append(' '); - } - - boolean firstPart = true; - for (String subPart : part.split("-")) { - if (subPart.length() == 0) { - continue; - } - - if (firstPart) { - firstPart = false; - } else { - result.append('-'); - } - result.append(Character.toUpperCase(subPart.charAt(0))); - result.append(subPart.substring(1)); - } - } - - return result.toString(); - } - } diff --git a/phoneblock/src/main/java/de/haumacher/phoneblock/mail/mail-template.html b/phoneblock/src/main/java/de/haumacher/phoneblock/mail/mail-template.html index 83f0a2a2..e2202a4f 100644 --- a/phoneblock/src/main/java/de/haumacher/phoneblock/mail/mail-template.html +++ b/phoneblock/src/main/java/de/haumacher/phoneblock/mail/mail-template.html @@ -1,6 +1,6 @@ -PhoneBlock account creation +PhoneBlock login code @@ -9,11 +9,11 @@

-Hallo PhoneBlock-Nutzer, +Hallo {name},

-hier kommt der Bestätigungscode für Deinen PhoneBlock-Account. Um Deine E-Mail-Adresse zu verifizieren, +hier kommt der Anmeldecode für Deinen PhoneBlock-Account. Um Deine E-Mail-Adresse zu verifizieren, trage bitte den folgenden Code in die Anmelde-Maske ein, die Du gerade in Deinem Browser offen hast:

@@ -22,7 +22,7 @@

-Wenn Du keinen PhoneBlock-Account erstellen willst, kannst Du diese E-Mail getrost ignorieren. +Wenn Du Dich nicht bei PhoneBlock anmelden willst, kannst Du diese E-Mail getrost ignorieren.

diff --git a/phoneblock/src/main/java/de/haumacher/phoneblock/mail/mail-template.txt b/phoneblock/src/main/java/de/haumacher/phoneblock/mail/mail-template.txt index b7fb7971..c25a4c5c 100644 --- a/phoneblock/src/main/java/de/haumacher/phoneblock/mail/mail-template.txt +++ b/phoneblock/src/main/java/de/haumacher/phoneblock/mail/mail-template.txt @@ -1,11 +1,11 @@ -Hallo PhoneBlock-Nutzer, +Hallo {name}, -hier kommt der Bestätigungscode für Deinen PhoneBlock-Account. Um Deine E-Mail-Adresse zu verifizieren, +hier kommt der Anmeldecode für Deinen PhoneBlock-Account. Um Deine E-Mail-Adresse zu verifizieren, trage bitte den folgenden Code in die Anmelde-Maske ein, die Du gerade in Deinem Browser offen hast: {code} -Wenn Du keinen PhoneBlock-Account erstellen willst, kannst Du diese E-Mail getrost ignorieren. +Wenn Du Dich nicht bei PhoneBlock anmelden willst, kannst Du diese E-Mail getrost ignorieren. Vielen Dank für Dein Interesse an PhoneBlock! Dein PhoneBlock-Server diff --git a/phoneblock/src/main/java/de/haumacher/phoneblock/users/UserAdd.java b/phoneblock/src/main/java/de/haumacher/phoneblock/users/UserAdd.java index f4dff2fc..84914a30 100644 --- a/phoneblock/src/main/java/de/haumacher/phoneblock/users/UserAdd.java +++ b/phoneblock/src/main/java/de/haumacher/phoneblock/users/UserAdd.java @@ -36,7 +36,7 @@ public static void main(String[] args) throws SQLException, IOException { } else { login = args[0]; } - String passwd = db.createUser(RegistrationServlet.IDENTIFIED_BY_EMAIL, login, login, login); + String passwd = db.createUser(login, login); System.out.println(passwd); diff --git a/phoneblock/src/main/webapp/anrufbeantworter/index.jsp b/phoneblock/src/main/webapp/anrufbeantworter/index.jsp index e655b63c..bdf38a21 100644 --- a/phoneblock/src/main/webapp/anrufbeantworter/index.jsp +++ b/phoneblock/src/main/webapp/anrufbeantworter/index.jsp @@ -68,21 +68,11 @@ if (userName == null) { %>

- Als erstes musst Du Dich - bei PhoneBlock registrieren. - Wenn Du bereits einen PhoneBlock-Account hast, melde Dich an. + Als erstes musst Du Dich bei PhoneBlock registrieren bzw. anmelden, um mit der Einrichtung zu beginnen.

- -
+
@@ -105,12 +95,12 @@
- +
<%= JspUtil.quote(userName) %>

Diesen Wert musst du als Benutzernamen für den Abruf der Blocklist eintragen.

-
<%= JspUtil.quote(token) %>
+
<%= JspUtil.quote(token) %>

Dieses Passwort musst Du für die Anmeldung an dieser Webseite verwenden.

Bitte notiere Dir das Passwort (oder speichere es am besten in einem Passwort-Manager), @@ -144,7 +134,7 @@

- DynDNS einrichten + DynDNS einrichten
@@ -165,7 +155,7 @@
- DynDNS einrichten + DynDNS einrichten
@@ -175,7 +165,7 @@
- DynDNS einrichten + DynDNS einrichten
@@ -391,7 +381,7 @@
- Zugriff aus dem Internet + Zugriff aus dem Internet
@@ -402,7 +392,7 @@
- Anrufbeantworter verbunden + Anrufbeantworter verbunden
diff --git a/phoneblock/src/main/webapp/error-not-allowed.jsp b/phoneblock/src/main/webapp/error-not-allowed.jsp index 7d359dca..57ebfc77 100644 --- a/phoneblock/src/main/webapp/error-not-allowed.jsp +++ b/phoneblock/src/main/webapp/error-not-allowed.jsp @@ -1,4 +1,6 @@ +<%@page import="de.haumacher.phoneblock.app.SettingsServlet"%> +<%@page import="de.haumacher.phoneblock.app.LoginServlet"%> <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" isErrorPage="true" session="false"%> @@ -13,7 +15,7 @@

Diese Seite kann nicht im Browser angezeigt werden

- Deinen Addressbuch-Link, den Du bei der Anmeldung + Deinen Addressbuch-Link, den Du bei der Anmeldung erhalten hast, musst Du wie in der Installationsanleitung beschrieben zusammen mit Deiner E-Mail-Adresse und dem Dir zugeschickten Passwort in Deiner @@ -26,9 +28,9 @@

diff --git a/phoneblock/src/main/webapp/faq.jsp b/phoneblock/src/main/webapp/faq.jsp index fba72e27..f5113f45 100644 --- a/phoneblock/src/main/webapp/faq.jsp +++ b/phoneblock/src/main/webapp/faq.jsp @@ -286,7 +286,7 @@
- +

Klar zum Loslegen?

PhoneBlock-Account erstellen!

diff --git a/phoneblock/src/main/webapp/header.jspf b/phoneblock/src/main/webapp/header.jspf index 178b4006..fd241fbd 100644 --- a/phoneblock/src/main/webapp/header.jspf +++ b/phoneblock/src/main/webapp/header.jspf @@ -94,13 +94,6 @@ + +<% + Object emailMessage = request.getAttribute(EMailVerificationServlet.VERIFY_ERROR_ATTR); + boolean emailError = emailMessage != null; + String emailActive = emailError ? "is-active" : ""; + String inputClass = emailError ? "input is-danger" : "input"; +%> + +<% + boolean loginError = request.getAttribute(LoginServlet.LOGIN_ERROR_ATTR) != null; + String userActive = loginError ? "is-active" : ""; +%> + diff --git a/phoneblock/src/main/webapp/phone-info.jsp b/phoneblock/src/main/webapp/phone-info.jsp index 42ee3235..d5f99d39 100644 --- a/phoneblock/src/main/webapp/phone-info.jsp +++ b/phoneblock/src/main/webapp/phone-info.jsp @@ -509,7 +509,7 @@
- + ">

PhoneBlock installieren

Noch nicht installiert? Dann los!

@@ -522,7 +522,7 @@
- + ">

PhoneBlock installieren

Account erstellen und einrichten!

diff --git a/phoneblock/src/main/webapp/phoneblock-style.css b/phoneblock/src/main/webapp/phoneblock-style.css index 4b3228bb..ff08a925 100644 --- a/phoneblock/src/main/webapp/phoneblock-style.css +++ b/phoneblock/src/main/webapp/phoneblock-style.css @@ -112,3 +112,12 @@ .token { padding-right:5px; } + +.copyToClipboard { + padding-left: 0.5ex; +} + +.appscreen { + border: 5px solid #555; + border-radius: 10px; +} \ No newline at end of file diff --git a/phoneblock/src/main/webapp/settings.jsp b/phoneblock/src/main/webapp/settings.jsp index f00d25a4..0b563c24 100644 --- a/phoneblock/src/main/webapp/settings.jsp +++ b/phoneblock/src/main/webapp/settings.jsp @@ -45,7 +45,8 @@ UserSettings settings = DBService.getInstance().getSettings(userName); %>

- Wilkommen <%= JspUtil.quote(settings.getDisplayName()) %>. + Willkommen <%= JspUtil.quote(settings.getDisplayName()) %><% if (settings.getEmail() != null) { %> + (<%= JspUtil.quote(settings.getEmail()) %>)<% } %>.

@@ -60,20 +61,24 @@
-
https://phoneblock.net<%=request.getContextPath() %>/contacts/
+
https://phoneblock.net<%=request.getContextPath() %>/contacts/
<% } %>
-
<%= JspUtil.quote(userName) %>
-

Diesen Wert musst du als Benutzernamen für den Abruf der Blocklist eintragen.

+
<%= JspUtil.quote(userName) %>
+

+ Diesen Wert musst du als Benutzernamen für den Abruf der Blocklist eintragen. + Dein Passwort wurde Dir nach Deiner ersten Anmeldung angezeigt. Wenn du dieses nicht mehr weißt, dann kannst Du unten auf der Seite + ein neues Passwort erstellen lassen. Aber Vorsicht: Das alte Passwort wird dadurch ungültig. +

<% if (token != null) { %>
-
<%= JspUtil.quote(token) %>
+
<%= JspUtil.quote(token) %>

Dieses Passwort musst Du für die Einrichtung des Telefonbuchs oder für die Anmeldung an dieser Webseite verwenden.

Bitte notiere Dir das Passwort (oder speichere es am besten in einem Passwort-Manager), diff --git a/phoneblock/src/main/webapp/setup-android/03-people-sync-install.jsp b/phoneblock/src/main/webapp/setup-android/03-people-sync-install.jsp index e109d02d..d9ecc382 100644 --- a/phoneblock/src/main/webapp/setup-android/03-people-sync-install.jsp +++ b/phoneblock/src/main/webapp/setup-android/03-people-sync-install.jsp @@ -24,11 +24,11 @@

- Installiere PeopleSync + Installiere PeopleSync
- Öffne PeopleSync + Öffne PeopleSync
diff --git a/phoneblock/src/main/webapp/setup-android/05-people-sync-accept.jsp b/phoneblock/src/main/webapp/setup-android/05-people-sync-accept.jsp index 3042db51..a86e2a43 100644 --- a/phoneblock/src/main/webapp/setup-android/05-people-sync-accept.jsp +++ b/phoneblock/src/main/webapp/setup-android/05-people-sync-accept.jsp @@ -22,10 +22,10 @@
- Berechtigungen + Berechtigungen
- Sync-Intervalle + Sync-Intervalle
diff --git a/phoneblock/src/main/webapp/setup-android/07-people-sync-add.jsp b/phoneblock/src/main/webapp/setup-android/07-people-sync-add.jsp index 491bc6fc..87ad896b 100644 --- a/phoneblock/src/main/webapp/setup-android/07-people-sync-add.jsp +++ b/phoneblock/src/main/webapp/setup-android/07-people-sync-add.jsp @@ -27,29 +27,29 @@
  1. - Wähle die Option "Mit URL und Benutzername anmelden" und gib als "Basis-URL" die Adresse des PhoneBlock-Adressbuchs an: https://phoneblock.net<%=request.getContextPath() %>/contacts/ . + Wähle die Option "Mit URL und Benutzername anmelden" und gib als "Basis-URL" die Adresse des PhoneBlock-Adressbuchs an: https://phoneblock.net<%=request.getContextPath() %>/contacts/.
  2. - Bei "Benutzername" trägst Du den Benutzernamen ein, den Du bei der PhoneBlock-Anmeldung erhalten hast<%if (login != null) {%> (<%= login %> )<%}%>. + Bei "Benutzername" trägst Du den Benutzernamen ein, den Du bei der PhoneBlock-Anmeldung erhalten hast<%if (login != null) {%> (<%= login %>)<%}%>.
  3. - Das Passwort wurde dir nach erfolgreicher Registrierung angezeigt<% if (token != null) {%> (<%= token %> )<%}%>. + Das Passwort wurde dir nach der ersten Anmeldung angezeigt<% if (token != null) {%> (<%= token %>)<%}%>.

Du hast die Daten nicht mehr zur Hand? Macht nichts, einfach - erneut registrieren oder in den Einstellungen das Passwort zurücksetzen. + anmelden und in den Einstellungen das Passwort zurücksetzen.

- Adressbuch hinzufügen + Adressbuch hinzufügen
- Adressbuch hinzufügen + Adressbuch hinzufügen
diff --git a/phoneblock/src/main/webapp/setup-android/09-people-sync-account-finished.jsp b/phoneblock/src/main/webapp/setup-android/09-people-sync-account-finished.jsp index e7f870ac..99351c87 100644 --- a/phoneblock/src/main/webapp/setup-android/09-people-sync-account-finished.jsp +++ b/phoneblock/src/main/webapp/setup-android/09-people-sync-account-finished.jsp @@ -22,10 +22,10 @@
- Konto ist eingerichtet + Konto ist eingerichtet
- Aboniere die Blocklist + Aboniere die Blocklist
diff --git a/phoneblock/src/main/webapp/setup-android/11-spam-contacts.jsp b/phoneblock/src/main/webapp/setup-android/11-spam-contacts.jsp index 595c67ce..0eec8d8d 100644 --- a/phoneblock/src/main/webapp/setup-android/11-spam-contacts.jsp +++ b/phoneblock/src/main/webapp/setup-android/11-spam-contacts.jsp @@ -22,7 +22,7 @@
- Konto ist eingerichtet + Konto ist eingerichtet
diff --git a/phoneblock/src/main/webapp/setup-android/index.jsp b/phoneblock/src/main/webapp/setup-android/index.jsp index 09cdab3a..3c848680 100644 --- a/phoneblock/src/main/webapp/setup-android/index.jsp +++ b/phoneblock/src/main/webapp/setup-android/index.jsp @@ -34,11 +34,11 @@
- Öffne Playstore + Öffne Playstore
- Suche nach PeopleSync + Suche nach PeopleSync
diff --git a/phoneblock/src/main/webapp/setup-iphone/index.jsp b/phoneblock/src/main/webapp/setup-iphone/index.jsp index 7f3a1730..e73acb51 100644 --- a/phoneblock/src/main/webapp/setup-iphone/index.jsp +++ b/phoneblock/src/main/webapp/setup-iphone/index.jsp @@ -37,18 +37,18 @@ %>
    -
  1. Melde Dich bei PhoneBlock an.
  2. +
  3. Melde Dich bei PhoneBlock an.
  4. Öffne "Einstellungen" > "Kontakte" > "Accounts".
  5. Tippe auf "Account hinzufügen" - "Andere" > "CardDAV-Account hinzufügen".
  6. Gib deine Zugangsdaten ein und tippe auf "Weiter".
    Server
    -
    https://phoneblock.net<%=request.getContextPath() %>/contacts/
    +
    https://phoneblock.net<%=request.getContextPath() %>/contacts/
    Benutzername
    <%if (login != null) {%> - <%= login %> + <%= login %> <%} else {%> Wurde Dir direkt nach der Anmeldung angezeigt. <%}%> @@ -57,7 +57,7 @@
    Passwort
    <% if (token != null) {%> - <%= token %> + <%= token %> <%} else {%> Wurde Dir direkt nach der Anmeldung angezeigt. <%}%> @@ -73,7 +73,7 @@

    Du hast die Zugangsdaten nicht mehr zur Hand? Macht nichts, einfach - erneut registrieren oder in den Einstellungen das Passwort zurücksetzen. + anmelden und in den Einstellungen das Passwort zurücksetzen.

    diff --git a/phoneblock/src/main/webapp/setup.jsp b/phoneblock/src/main/webapp/setup.jsp index f386a938..8ca26e90 100644 --- a/phoneblock/src/main/webapp/setup.jsp +++ b/phoneblock/src/main/webapp/setup.jsp @@ -1,4 +1,5 @@ +<%@page import="de.haumacher.phoneblock.app.SettingsServlet"%> <%@page import="de.haumacher.phoneblock.app.RegistrationServlet"%> <%@page import="de.haumacher.phoneblock.app.LoginFilter"%> <%@page import="de.haumacher.phoneblock.app.LoginServlet"%> @@ -25,9 +26,7 @@ Object token = RegistrationServlet.getPassword(session); %> -<% - if (token == null) { -%> +<% if (token == null) { %>

    Für die Installation der Blockliste benötigst Du einen "FRITZ!Box" Internetrouter von AVM und einen PhoneBlock-Account. Es muss nicht unbedingt das neuste Modell @@ -43,17 +42,21 @@ PhoneBlock-Anrufbeantworters den besseren Schutz vor SPAM-Anrufen.

    - + +<% if (login == null) { %> -<% - } else { -%> +<% } else { %> +

    + Du bist bereits als <%= JspUtil.quote(login) %> angemeldet, prima! Du kannst sofort loslegen. +

    +<% } %> +<% } else { %>
    @@ -65,17 +68,17 @@
    -
    https://phoneblock.net<%=request.getContextPath() %>/contacts/
    +
    https://phoneblock.net<%=request.getContextPath() %>/contacts/
    -
    <%= JspUtil.quote(login) %>
    +
    <%= JspUtil.quote(login) %>
    -
    <%= JspUtil.quote(token) %>
    +
    <%= JspUtil.quote(token) %>
    @@ -83,9 +86,7 @@
-<% - } -%> +<% } %>

Melde Dich an Deiner FRITZ!Box an

@@ -130,42 +131,52 @@ Jetzt benötigst Du die Anmelde-Daten Deines PhoneBlock-Accounts.

-

- 1 - gib dem Telefonbuch, das als Sperrliste dienen soll, den Namen Blocklist. Du benötigst diesen - Namen nochmals für den nächsten Schritt. Wähle jetzt 2 die Option - Telefonbuch eines Online-Anbieters nutzen aus. Dann kannst Du 3 - den Anbieter CardDAV-Anbieter wählen. -

+
    +
  • + 1 + gib dem Telefonbuch, das als Sperrliste dienen soll, den Namen Blocklist. Du benötigst diesen + Namen nochmals für den nächsten Schritt. +
  • -

    - Fast geschafft, jetzt kommen die Anmeldedaten 4! Trage die URL - von des PhoneBlock-Adressbuchs in das Feld Internetadresse des CardDAV-Servers ein: -

    - -
    -
    - https://phoneblock.net<%=request.getContextPath() %>/contacts/ -
    -
    - -

    - Trage den Benutzernamen <%if (login != null) {%> <%= JspUtil.quote(login) %> <%} %>, den Du bei der - Registrierung erhalten hast, in das Feld - Benutzername ein. Am besten überträgst Du ihn mit Cut&Paste. -

    - -

    - Das Passwort<%if (token == null) {%>, - das Du bei der Registrierung erhalten - hast, <%} else {%> <%= JspUtil.quote(token) %> ,<%}%> muss Du jetzt noch in das Feld - Passwort in dem Formular in der Fritz!Box eintragen. -

    - -

    - Jetzt kannst Du 5 die Anlage des neuen Telefonbuchs bestätigen. Bitte beachte: Wähle keines Deiner Telefone - bei dem Punkt "Telefon-Zuordnung" aus! Ansonsten findest Du auf Deinem Telefon nur noch SPAM-Anrufer in den Kontakten. -

    +
  • + Wähle jetzt 2 die Option + Telefonbuch eines Online-Anbieters nutzen aus. +
  • + +
  • + Dann kannst Du 3 + den Anbieter CardDAV-Anbieter wählen. +
  • + +
  • + Fast geschafft, jetzt kommen die Anmeldedaten 4. Am besten Du überträgst sie mit Cut&Paste, um Tippfehler zu vermeiden! + +
      +
    • + Trage die URL von des PhoneBlock-Adressbuchs in das Feld Internetadresse des CardDAV-Servers ein: + https://phoneblock.net<%=request.getContextPath() %>/contacts/ +
    • + +
    • + Trage den Benutzernamen <%if (login != null) {%> <%= JspUtil.quote(login) %><%} %>, den Du bei der + Registrierung erhalten hast, in das Feld + Benutzername ein. +
    • + +
    • + Das Passwort<%if (token == null) {%>, + das Du bei der Registrierung erhalten + hast, <%} else {%> <%= JspUtil.quote(token) %>,<%}%> muss Du jetzt noch in das Feld + Passwort eintragen werden. +
    • +
    +
  • + +
  • + Jetzt kannst Du 5 die Anlage des neuen Telefonbuchs bestätigen. Bitte beachte: Wähle keines Deiner Telefone + bei dem Punkt "Telefon-Zuordnung" aus! Ansonsten findest Du auf Deinem Telefon nur noch SPAM-Anrufer in den Kontakten. +
  • +
diff --git a/phoneblock/src/main/webapp/signup-code.jsp b/phoneblock/src/main/webapp/signup-code.jsp index 63ff64bd..359e0d15 100644 --- a/phoneblock/src/main/webapp/signup-code.jsp +++ b/phoneblock/src/main/webapp/signup-code.jsp @@ -1,4 +1,5 @@ +<%@page import="de.haumacher.phoneblock.app.EMailVerificationServlet"%> <%@page import="de.haumacher.phoneblock.app.RegistrationServlet"%> <%@page import="de.haumacher.phoneblock.app.LoginServlet"%> <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" session="false"%> @@ -17,12 +18,13 @@
-

E-Mail bestätigen

- -

- Eine E-Mail wurde an die Adresse <%= JspUtil.quote(request.getAttribute("email")) %> gesendet. - Bitte schau in Deiner Mailbox nach und kopiere den Code. -

+<% +String location = LoginServlet.location(request); +Object errorMessage = request.getAttribute(RegistrationServlet.REGISTER_ERROR_ATTR); +boolean hasError = errorMessage != null; +String inputClass = hasError ? "input is-danger" : "input"; +Object rememberMe = request.getParameter(LoginServlet.REMEMBER_PARAM); +%>
@@ -33,61 +35,45 @@

E-Mail-Adresse bestätigen.

- Bitte bestätige Deine E-Mail-Adresse, indem Du den Code aus der Anmelde-E-Mail hier eingibst. + Eine E-Mail wurde an die Adresse <%= JspUtil.quote(request.getAttribute("email")) %> gesendet. + Bitte schau in Deiner Mailbox nach und gib den Code hier ein.

-<% - String location = LoginServlet.location(request); -%>
-<% - Object message = request.getAttribute("message"); -%>
- <% - if (location != null) { - %> +<% if (location != null) { %> - <% - } - %> +<% } %> +<% if (rememberMe != null) { %> + +<% } %> - " type="text" placeholder="Bestätigungscode" value=""> + -<% - if (message != null) { -%> +<% if (hasError) { %> -<% - } -%> +<% } %>
-<% - if (message != null) { -%> +<% if (hasError) { %>

- <%= JspUtil.quote(request.getAttribute("message")) %> - Nochmal probieren. + <%= JspUtil.quote(errorMessage) %> + Nochmal probieren.

-<% - } else { -%> +<% } else { %>

Keine E-Mail erhalten? Prüfe bitte Deinen Spam-Ordner! - Nochmal probieren. + Nochmal probieren.

-<% - } -%> +<% } %>
- +
diff --git a/phoneblock/src/main/webapp/signup.jsp b/phoneblock/src/main/webapp/signup.jsp index 2666991f..b833340f 100644 --- a/phoneblock/src/main/webapp/signup.jsp +++ b/phoneblock/src/main/webapp/signup.jsp @@ -1,108 +1,5 @@ - -<%@page import="de.haumacher.phoneblock.app.EMailVerificationServlet"%> -<%@page import="de.haumacher.phoneblock.app.SettingsServlet"%> -<%@page import="java.net.URLEncoder"%> -<%@page import="de.haumacher.phoneblock.app.LoginServlet"%> -<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" session="false"%> -<%@page import="de.haumacher.phoneblock.util.JspUtil"%> -<%@page import="de.haumacher.phoneblock.app.oauth.PhoneBlockConfigFactory"%> - <% - request.setAttribute("title", "PhoneBlock Account erstellen"); -%> - - - - - - - -
-
- -

Registrierung

- -

- Um PhoneBlock in Deinem Internet-Router zu installieren, benötigst Du einen Benutzernamen und ein Passwort. Beides - erhältst Du bei der Registrierung. In der Installationsanleitung - erfährst Du, wie Du anschließend die Blocklist abrufen und Anrufer mit diesen Telefonnummern blockieren kannst. -

- -
- - <% - String location = LoginServlet.location(request, SettingsServlet.PATH); - String locationParam = LoginServlet.locationParam(location); - String locationParamFirst = LoginServlet.locationParamFirst(location); - %> - - - -<% - Object message = request.getAttribute("message"); - String active = message != null ? "is-active" : ""; -%> - - -
- - - - \ No newline at end of file + // Page does no longer exist. + response.sendRedirect(request.getContextPath() + "/login.jsp"); + return; +%> \ No newline at end of file diff --git a/phoneblock/src/main/webapp/sitemap.jsp b/phoneblock/src/main/webapp/sitemap.jsp index b792326c..88483071 100644 --- a/phoneblock/src/main/webapp/sitemap.jsp +++ b/phoneblock/src/main/webapp/sitemap.jsp @@ -71,7 +71,7 @@ - https://phoneblock.net/phoneblock/signup.jsp + https://phoneblock.net/phoneblock/login.jsp ${maven.build.timestamp} monthly 0.5 diff --git a/phoneblock/src/main/webapp/support-banktransfer.jsp b/phoneblock/src/main/webapp/support-banktransfer.jsp index 91e79f2e..510fbe07 100644 --- a/phoneblock/src/main/webapp/support-banktransfer.jsp +++ b/phoneblock/src/main/webapp/support-banktransfer.jsp @@ -20,7 +20,7 @@

Vielen Dank, dass Du Dich an den Kosten von PhoneBlock beteiligst. Wenn viele mitmachen, reicht ein kleiner Betrag reicht aus, z.B. - 1€ pro Jahr oder 0,01€ pro abgefangenem Spam-Anruf, Du kannst die höhe Deines Beitrages aber selbst wählen. + 1€ pro Jahr oder 0,01€ pro abgefangenem Spam-Anruf, Du kannst die Höhe Deines Beitrages aber selbst wählen.

@@ -28,10 +28,10 @@

    -
  • Empfänger: ${bank.receiver}
  • -
  • Kontonummer: ${bank.account}
  • -
  • BIC: ${bank.bic}
  • -
  • Verwendungszweck: PhoneBlock-<%= LoginFilter.getAuthenticatedUser(request.getSession()).substring(0, 13)%>
  • +
  • Empfänger: ${bank.receiver}
  • +
  • Kontonummer: ${bank.account}
  • +
  • BIC: ${bank.bic}
  • +
  • Verwendungszweck: PhoneBlock-<%= LoginFilter.getAuthenticatedUser(request.getSession()).substring(0, 13)%>

diff --git a/phoneblock/src/main/webapp/support.jsp b/phoneblock/src/main/webapp/support.jsp index b0cc6761..8b15b088 100644 --- a/phoneblock/src/main/webapp/support.jsp +++ b/phoneblock/src/main/webapp/support.jsp @@ -53,7 +53,7 @@

<% } else { %>

- Bitte gibt PhoneBlock-<%= userName.substring(0, 13)%> mit als Nachricht ein, damit ich die Zahlung zuordnen kann. + Bitte gibt PhoneBlock-<%= userName.substring(0, 13)%> mit als Nachricht ein, damit ich die Zahlung zuordnen kann.

<% } %> diff --git a/phoneblock/src/test/java/de/haumacher/phoneblock/db/TestDB.java b/phoneblock/src/test/java/de/haumacher/phoneblock/db/TestDB.java index ea26b91b..be4c5819 100644 --- a/phoneblock/src/test/java/de/haumacher/phoneblock/db/TestDB.java +++ b/phoneblock/src/test/java/de/haumacher/phoneblock/db/TestDB.java @@ -70,7 +70,7 @@ public void tearDown() throws Exception { @Test void testAuthToken() { - _db.createUser("test", "test1", "user1", "User 1"); + _db.createUser("user1", "User 1"); long time = 1000; final long createTime = time; @@ -264,8 +264,8 @@ void testDuplicateAdd() { @Test void testUserManagement() throws IOException { - _db.addUser("none", "1", "foo@bar.com", "Mr. X", "123"); - _db.addUser("none", "2", "baz@bar.com", "Mr. Y", "123"); + _db.addUser("foo@bar.com", "Mr. X", "123"); + _db.addUser("baz@bar.com", "Mr. Y", "123"); assertEquals("foo@bar.com", _db.basicAuth(header("foo@bar.com", "123"))); assertNull(_db.basicAuth(header("foo@bar.com", "321"))); @@ -446,7 +446,7 @@ protected void checkPhone(String phone, int votes, int cnt10, int votes10, int c @Test void testRating() { - _db.createUser("domain", "ext-1", "user-1", "User 1"); + _db.createUser("user-1", "User 1"); long time = 1;