Package NTNU.IDATT1002.service
Class UserService
java.lang.Object
NTNU.IDATT1002.service.UserService
public class UserService
extends java.lang.Object
Works together with loginrepository and userrepository
Combines authentication and connections to database through repositories
- Version:
- 1.0 22.03.20
- Author:
- madslun
-
Constructor Summary
Constructors Constructor Description UserService(javax.persistence.EntityManager entityManager)
Inject entity manager instance to the repositories -
Method Summary
Modifier and Type Method Description java.util.Optional<User>
createUser(java.lang.String email, java.lang.String username, java.lang.String firstName, java.lang.String lastName, java.lang.String callingCode, java.lang.String phoneNumber, java.util.Date birthDate, java.lang.String password)
Creates a new user and sets password on the new userjava.util.List<User>
getUsers()
boolean
logIn(java.lang.String username, java.lang.String password)
Logs a user in if correct credentials is givenstatic void
logOut()
-
Constructor Details
-
UserService
public UserService(javax.persistence.EntityManager entityManager)Inject entity manager instance to the repositories
-
-
Method Details
-
createUser
public java.util.Optional<User> createUser(java.lang.String email, java.lang.String username, java.lang.String firstName, java.lang.String lastName, java.lang.String callingCode, java.lang.String phoneNumber, java.util.Date birthDate, java.lang.String password)Creates a new user and sets password on the new user- Parameters:
email
- that will added to the userusername
- that will be registered to the userfirstName
- of the userlastName
- of the usercallingCode
- of the phone numberphoneNumber
- of the userbirthDate
- of the userpassword
- that will be set to login- Returns:
- Optional with the user
-
logIn
public boolean logIn(java.lang.String username, java.lang.String password)Logs a user in if correct credentials is given- Parameters:
username
- that will be checked againstpassword
- that will be compared to database- Returns:
-
logOut
public static void logOut() -
getUsers
-