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 user
    java.util.List<User> getUsers()  
    boolean logIn​(java.lang.String username, java.lang.String password)
    Logs a user in if correct credentials is given
    static void logOut()  

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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 user
      username - that will be registered to the user
      firstName - of the user
      lastName - of the user
      callingCode - of the phone number
      phoneNumber - of the user
      birthDate - of the user
      password - 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 against
      password - that will be compared to database
      Returns:
    • logOut

      public static void logOut()
    • getUsers

      public java.util.List<User> getUsers()