Projekt

Obecné

Profil

« Předchozí | Další » 

Revize 9f856c9f

Přidáno uživatelem Jiri Trefil před asi 2 roky(ů)

#10244 aktualizace komentářů

Zobrazit rozdíly:

src/main/java/cz/zcu/fav/kiv/antipatterndetectionapp/v2/service/UserServiceImpl.java
25 25
    /**
26 26
     * Method attempts to register a user
27 27
     * @param user serialized JSON object representing user
28
     * @return Integer flag:
29
     *  1 - if the user is registered successfully
30
     *  0 - if the user request violates constraints of column(s)
31
     *  -1 - if the username is already taken
32
     *
28
     * @return  Enum code UserModelStatusCodes.
29
     *      INVALID_USER_ARGUMENTS      if user send invalid name, email or password
30
     *      USER_EXISTS                 if user send name, which is already taken
31
     *      HASH_FAILED                 if hash function failed
32
     *      USER_CREATION_FAILED        if there is problem with database
33
     *      USER_CREATED                if user were created (happy-day)
33 34
     */
34 35
    @Override
35 36
    public UserModelStatusCodes registerUser(User user) {
......
105 106
    /**
106 107
     * Method
107 108
     * @param user serialized JSON object representing user
108
     * @return Integer Flag:
109
     *      0 - if username is not registered
110
     *      1 - if user is logged successfully
109
     * @return  Enum flag UserModelStatusCodes.
110
     *      USER_LOGGED_IN     if user has right name and password
111
     *      USER_LOGIN_FAILED  if user has wrong name or password
111 112
     */
113

  
112 114
    @Override
113 115
    public UserModelStatusCodes loginUser(User user) {
114 116
        final String name = user.getName();
......
118 120
        }
119 121

  
120 122
        User u = userRepository.findByName(user.getName());
123

  
124
        if (u == null) {
125
            return UserModelStatusCodes.USER_LOGIN_FAILED;
126
        }
121 127
        //TODO request to OAuth for authentication
122 128
        final boolean passwordMatches = comparePassword(password,u.getPassword());
123 129

  

Také k dispozici: Unified diff