У меня есть приложение Play
. Доступ к домашней странице приложения можно получить с помощью URL http://localhost:9000/home
.
.
Я создал кнопку регистрации. При регистрации приложение создает URL-адрес и отправляет его пользователю по электронной почте
html
в письме довольно простое.
<a href=http://localhost:9000/ws/users/signup/ca67d0b4-8900-4672-a83d-e1eac1711333>Click here to verify email</a>
Длинный биг после /signup/
является токеном.
При нажатии на ссылку выше, вызывается действие verifyUser
моего приложения, которое после некоторой обработки просит клиента перенаправить на домашнюю страницу (упомянуто выше)
def verifyUser(token:String) = Action.async{
implicit request => {
println("verifyUser action called with token: "+token) //TODOM - add proper handling and response
val tokenFutureOption:Future[Option[UserToken]] = userTokenRepo.find(UserTokenKey(UUID.fromString(token)))
for(tokenOption<- tokenFutureOption) yield {
tokenOption match {
case Some(userToken) =>{
println("finding user for token "+token)
val userOptionFuture = userRepo.findUser(userToken.loginInfo)
for(userOption <- userOptionFuture) yield {
userOption match {
case Some(user) =>{
println("found user "+user + "for token "+token)
val newInternalProfile = user.profile.internalProfileDetails.get.copy(confirmed=true)
println("old internal profile: "+user.profile.internalProfileDetails.get)
println("new internal profile: "+newInternalProfile)
val newProfile = UserProfile(Some(newInternalProfile),user.profile.externalProfileDetails)
println("old profile: "+user.profile)
println("new profile: "+newProfile)
val confirmedUser = user.copy(profile=newProfile)
val userOptionFuture :Future[Option[User]] = userRepo.updateUser(confirmedUser)
for(userOption <- userOptionFuture) yield {
userTokenRepo.remove(UserTokenKey(UUID.fromString(token)))
}
}
case None =>{
println("user doesn't exist for token "+userToken)
}
}
}
Redirect("localhost:9000/home")
}
case None =>{
Redirect("localhost:9000/home")
}
}
}
}
}
Я получаю URL в электронном письме и, щелкая по нему, браузер переходит на URL http://localhost:9000/ws/users/signup/ca67d0b4-8900-4672-a83d-e1eac1711333
, вызывается verifyUser
Action
, но браузер не перенаправляет на localhost:9000/home
. Похоже, что браузер отправляет запрос на localhost:9000/home
, но не получает ответ от сервера. См. Рисунок ниже.
Что я делаю не так?
![enter image description here](https://i.stack.imgur.com/6yrje.png)