Skip to content

Commit

Permalink
fix: handle case if user has no main photo
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewbolotsky committed Jun 9, 2024
1 parent e5dea96 commit 18f8b04
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import java.nio.charset.StandardCharsets;
import java.util.concurrent.CompletableFuture;
import lombok.Getter;
import org.mindrot.jbcrypt.BCrypt;
import ru.hse.goodtrip.MainActivity;
import ru.hse.goodtrip.R;
import ru.hse.goodtrip.data.TripRepository;
Expand Down Expand Up @@ -52,8 +51,7 @@ public class AuthViewModel extends ViewModel {
*/
public void login(String username, String password) {

String hashedPassword = BCrypt.hashpw(password, BCrypt.gensalt());

String hashedPassword = String.valueOf(sha256().hashString(password, StandardCharsets.UTF_8));
CompletableFuture<Result<AuthenticationResponse>> result = usersRepository.login(username,
hashedPassword);
runExecutorToWaitResult(result,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,13 @@ public void findUser(String handleToFind, Consumer<User> workAfter) {
ru.hse.goodtrip.network.social.entities.User networkUser =
((Result.Success<ru.hse.goodtrip.network.social.entities.User>) result).getData();
try {
URL linkToPhoto = null;
if (networkUser.getImageLink() != null) {
linkToPhoto = new URL(networkUser.getImageLink());
}
return new User(networkUser.getId(), networkUser.getHandle(),
networkUser.getName() + " " + networkUser.getSurname(),
new URL(networkUser.getImageLink()), "");
linkToPhoto, "");
} catch (MalformedURLException e) {
Log.d(getClass().getSimpleName(),
Objects.requireNonNull(e.getLocalizedMessage()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,13 @@ private void updateUsers(Result<List<ru.hse.goodtrip.network.social.entities.Use
.getData()
.stream().map(networkUser -> {
try {
URL linkToPhoto = null;
if (networkUser.getImageLink() != null) {
linkToPhoto = new URL(networkUser.getImageLink());
}
return new User(networkUser.getId(), networkUser.getHandle(),
networkUser.getName() + " " + networkUser.getSurname(),
new URL(networkUser.getImageLink()), "");
linkToPhoto, "");
} catch (MalformedURLException e) {
Log.d(this.getClass().getSimpleName(),
Objects.requireNonNull(e.getLocalizedMessage()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,13 @@ private static ArrayList<User> getResult(
Success<List<ru.hse.goodtrip.network.social.entities.User>> newUsers) {
return newUsers.getData().stream().map(networkUser -> {
try {
URL linkToPhoto = null;
if (networkUser.getImageLink() != null) {
linkToPhoto = new URL(networkUser.getImageLink());
}
return new User(networkUser.getId(), networkUser.getHandle(),
networkUser.getName() + " " + networkUser.getSurname(),
new URL(networkUser.getImageLink()), "");
linkToPhoto, "");
} catch (MalformedURLException e) {
Log.e(ProfileFollowingViewModel.class.getSimpleName(),
Objects.requireNonNull(e.getLocalizedMessage()));
Expand Down

0 comments on commit 18f8b04

Please sign in to comment.