-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/development' into 12-user-settin…
…gs-provide-all-actions # Conflicts: # src/main/java/model/DAO/DAOUser.java
- Loading branch information
Showing
29 changed files
with
1,326 additions
and
126 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
package controller; | ||
|
||
import model.entity.PersonalInfo; | ||
import model.entity.User; | ||
import model.service.registration.Registration; | ||
import model.service.user.UserData; | ||
import model.service.user.UserRegistry; | ||
|
||
import javax.servlet.annotation.WebServlet; | ||
import javax.servlet.http.HttpServlet; | ||
import javax.servlet.http.HttpServletRequest; | ||
import javax.servlet.http.HttpServletResponse; | ||
import javax.servlet.http.HttpSession; | ||
import java.io.IOException; | ||
|
||
@WebServlet("/register") | ||
|
||
public class RegistrationServlet extends HttpServlet { | ||
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException { | ||
|
||
String licenseCode = request.getParameter("licenseCode"); | ||
String email = request.getParameter("email"); | ||
String password = request.getParameter("password"); | ||
String name = request.getParameter("name"); | ||
String surname = request.getParameter("surname"); | ||
|
||
Registration registration = new Registration(); | ||
int result = registration.registerNewUser(licenseCode, email, password, name, surname); | ||
response.setContentType("text/html"); | ||
response.setCharacterEncoding("UTF-8"); | ||
response.getWriter().write(String.valueOf(result)); | ||
if(result == 0) { | ||
setSessionAttributes(email, request); | ||
response.sendRedirect("/JSP/legal.jsp"); | ||
} | ||
} | ||
|
||
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException { | ||
UserData ud = new UserData(); | ||
HttpSession session = request.getSession(); | ||
String parameter = request.getParameter("type"); | ||
if(parameter.equals("analytics")) { | ||
Boolean value = Boolean.parseBoolean(request.getParameter("accept")); | ||
ud.updateAnalyticsPreference(String.valueOf(session.getAttribute("id")), value); | ||
} | ||
if(parameter.equals("emailTime")) { | ||
String start = request.getParameter("startTime"); | ||
String end = request.getParameter("endTime"); | ||
String time = start + "|" + end; | ||
ud.updateEmailTime(String.valueOf(session.getAttribute("id")), time); | ||
response.sendRedirect("/JSP/welcome.jsp"); | ||
} | ||
} | ||
|
||
private void setSessionAttributes(String email, HttpServletRequest request){ | ||
HttpSession session = request.getSession(); | ||
|
||
UserData userData = new UserData(); | ||
UserRegistry userReg = new UserRegistry(); | ||
|
||
User user = userData.getUserByIdOrEmail(email); | ||
PersonalInfo personalInfo = userReg.getPersonalInfo(user.getId()); | ||
|
||
session.setAttribute("id", user.getId()); | ||
session.setAttribute("name", personalInfo.getFirstname()); | ||
|
||
if(!userData.isTherapist(user)) { | ||
session.setAttribute("type", "patient"); | ||
session.setAttribute("therapist", user.getIdTherapist()); | ||
} | ||
else { | ||
session.setAttribute("type", "therapist"); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
*{ | ||
padding: 0; | ||
margin: 0; | ||
box-sizing: border-box; | ||
font-family: 'Poppins', sans-serif; | ||
text-decoration: none; | ||
list-style: none; | ||
} | ||
.return { | ||
display:flex; | ||
justify-content:center; | ||
width: 100%; | ||
} | ||
|
||
.return > button { | ||
width: 30%; | ||
border: none; | ||
padding: 15px 30px; | ||
border-radius: 5px; | ||
margin-bottom: 10px; | ||
} | ||
|
||
:root{ | ||
--bg-color: #222327; | ||
--text-color: #fff; | ||
--main-color: #29fd53 | ||
} |
Oops, something went wrong.