Uses only token now
Need to implement timeout later
This commit is contained in:
parent
77c5ffbb15
commit
0681105778
@ -103,11 +103,10 @@ class ApplicationController extends DefaultWindowController {
|
|||||||
final case class ApplicationName(name: String)
|
final case class ApplicationName(name: String)
|
||||||
final case class UserCredentials(
|
final case class UserCredentials(
|
||||||
username: String,
|
username: String,
|
||||||
password: String,
|
|
||||||
token: String
|
token: String
|
||||||
)
|
)
|
||||||
object UserCredentials {
|
object UserCredentials {
|
||||||
def empty = UserCredentials("empty", "empty", "empty")
|
def empty = UserCredentials("empty", "empty")
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApplicationScoped
|
@ApplicationScoped
|
||||||
|
@ -78,7 +78,7 @@ class LoginController @Inject() (
|
|||||||
case Some(token) =>
|
case Some(token) =>
|
||||||
async {
|
async {
|
||||||
val credentials =
|
val credentials =
|
||||||
UserCredentials(inputUserName, inputPassword, token)
|
UserCredentials(inputUserName, token)
|
||||||
appDataHandler.updateCredentials(credentials)
|
appDataHandler.updateCredentials(credentials)
|
||||||
updateErrorLabel("")
|
updateErrorLabel("")
|
||||||
applicationController.showChatPane()
|
applicationController.showChatPane()
|
||||||
|
@ -32,10 +32,13 @@ class UserService @Inject() (appDataHandler: AppDataHandler)(
|
|||||||
DefaultFormats ++ JavaTimeSerializers.all
|
DefaultFormats ++ JavaTimeSerializers.all
|
||||||
private val domain = "http://localhost:8080"
|
private val domain = "http://localhost:8080"
|
||||||
private lazy val baseUrl = uri"$domain/api/chat"
|
private lazy val baseUrl = uri"$domain/api/chat"
|
||||||
private lazy val authBasicRequest = (credentials: UserCredentials) =>
|
// private lazy val authBasicRequest = (credentials: UserCredentials) =>
|
||||||
basicRequest.auth
|
// basicRequest.auth
|
||||||
.basic(credentials.username, credentials.password)
|
// .basic(credentials.username, credentials.password)
|
||||||
.header("X-AUTH-TOKEN", credentials.token)
|
// .header("X-AUTH-TOKEN", credentials.token)
|
||||||
|
private lazy val tokenBasicRequest = (token: String) => {
|
||||||
|
basicRequest.header("X-AUTH-TOKEN", token)
|
||||||
|
}
|
||||||
|
|
||||||
def func1() = async {
|
def func1() = async {
|
||||||
val willBeResponse = func2()
|
val willBeResponse = func2()
|
||||||
@ -59,7 +62,8 @@ class UserService @Inject() (appDataHandler: AppDataHandler)(
|
|||||||
// )
|
// )
|
||||||
// )
|
// )
|
||||||
await {
|
await {
|
||||||
authBasicRequest(credentials)
|
// authBasicRequest(credentials)
|
||||||
|
tokenBasicRequest(credentials.token)
|
||||||
.get(uri"http://localhost:8080/api/chat/get/users")
|
.get(uri"http://localhost:8080/api/chat/get/users")
|
||||||
.response(asJson[List[String]])
|
.response(asJson[List[String]])
|
||||||
.send()
|
.send()
|
||||||
@ -69,7 +73,8 @@ class UserService @Inject() (appDataHandler: AppDataHandler)(
|
|||||||
def getMessages(credentials: UserCredentials) = async {
|
def getMessages(credentials: UserCredentials) = async {
|
||||||
// logger.debug(s"${appDataHandler.appData}")
|
// logger.debug(s"${appDataHandler.appData}")
|
||||||
await {
|
await {
|
||||||
authBasicRequest(credentials)
|
// authBasicRequest(credentials)
|
||||||
|
tokenBasicRequest(credentials.token)
|
||||||
.get(uri"http://localhost:8080/api/chat/get/users")
|
.get(uri"http://localhost:8080/api/chat/get/users")
|
||||||
.response(asJson[List[String]])
|
.response(asJson[List[String]])
|
||||||
.send()
|
.send()
|
||||||
@ -77,7 +82,8 @@ class UserService @Inject() (appDataHandler: AppDataHandler)(
|
|||||||
}
|
}
|
||||||
|
|
||||||
def getActiveUsers(credentials: UserCredentials) =
|
def getActiveUsers(credentials: UserCredentials) =
|
||||||
authBasicRequest(credentials)
|
// authBasicRequest(credentials)
|
||||||
|
tokenBasicRequest(credentials.token)
|
||||||
.get(uri"http://localhost:8080/api/chat/get/active-users")
|
.get(uri"http://localhost:8080/api/chat/get/active-users")
|
||||||
.response(asJson[List[ActiveUser]])
|
.response(asJson[List[ActiveUser]])
|
||||||
.send()
|
.send()
|
||||||
|
Loading…
Reference in New Issue
Block a user