diff --git a/src/main/java/com/example/cosmos_serversb/models/Users.java b/src/main/java/com/example/cosmos_serversb/models/Users.java index b4c1165..0c579ea 100644 --- a/src/main/java/com/example/cosmos_serversb/models/Users.java +++ b/src/main/java/com/example/cosmos_serversb/models/Users.java @@ -53,8 +53,8 @@ Session session = SessionManager.getInstance().getSession(); createToken(uId); - Password password = new Password(pw, uId); - User testUser = new User(name, uId, uri, iconImage);//名前、uId、ユーザーuri、パスワード、アイコンイメージを保存 + Password password = new Password(pw, uId);//パスワードとユーザー情報を紐づけ + User testUser = new User(name, uId, uri, iconImage);//名前、uId、ユーザーuri、アイコンイメージを保存 session.save(testUser); return testUser; } @@ -62,10 +62,14 @@ public static User setUser(String uId, String name, String pw, String iconImage) { Session session = SessionManager.getInstance().getSession(); List usersList = session.createQuery( "from User" ).list(); -// List passwordList = session.createQuery("from Password").list(); + List passwordList = session.createQuery("from Password").list(); for ( User user : (List) usersList ) { - if (user.getuId().equals(uId)) { + if (user.getuId().equals(uId)) { //if (user.getuId().equals(uId) || password.getPw().equals(pw)) { user.setName(name); + for ( Password password : (List) passwordList ) { + password.setPw(pw); + session.update(password); + } if(iconImage != null) { user.setIconUri(iconImage); } @@ -73,15 +77,6 @@ break; } } - /* - for ( Password password : (List) passwordList ) { - if (password.getPw().equals(pw)) { - password.setPw(newpw); - session.update(password); - break; - } - } - */ User findUser = (User) session.load(User.class, uId); return findUser; }