Skip to content

Commit

Permalink
document API account info and logout
Browse files Browse the repository at this point in the history
  • Loading branch information
ornicar committed Jul 21, 2014
1 parent 6cce033 commit 93ea6b0
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 9 deletions.
10 changes: 10 additions & 0 deletions app/controllers/Account.scala
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,16 @@ object Account extends LilaController {
Ok(html.account.passwd(me, forms.passwd)).fuccess
}

def info = Auth { implicit ctx =>
me =>
negotiate(
html = notFound,
api = apiVersion => fuccess {
Ok(Env.user.jsonView me me) as JSON
}
)
}

def passwdApply = AuthBody { implicit ctx =>
me =>
implicit val req = ctx.body
Expand Down
15 changes: 6 additions & 9 deletions app/controllers/Auth.scala
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,12 @@ object Auth extends LilaController {
}

def logout = Open { implicit ctx =>
gotoLogoutSucceeded(ctx.req) fuccess
implicit val req = ctx.req
req.session get "sessionId" foreach lila.security.Store.delete
negotiate(
html = fuccess(Redirect(routes.Lobby.home)),
api = apiVersion => fuccess(Ok("ok") as JSON)
) map (_ withCookies LilaCookie.newSession)
}

def signup = Open { implicit ctx =>
Expand Down Expand Up @@ -92,12 +97,4 @@ object Auth extends LilaController {
)
}
}

private def gotoLogoutSucceeded(implicit req: RequestHeader) = {
req.session get "sessionId" foreach lila.security.Store.delete
logoutSucceeded(req) withCookies LilaCookie.newSession
}

private def logoutSucceeded(req: RequestHeader): Result =
Redirect(routes.Lobby.home)
}
1 change: 1 addition & 0 deletions conf/routes
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ GET /account/close controllers.Account.close
POST /account/closeConfirm controllers.Account.closeConfirm
GET /account/profile controllers.Account.profile
POST /account/profile controllers.Account.profileApply
GET /account/info controllers.Account.info

# Site
GET /socket controllers.Main.websocket
Expand Down
19 changes: 19 additions & 0 deletions doc/mobile-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,25 @@ Set-Cookie: lila2="3b5cc8c80f0af258a31dc4fd1b5381cabe7388c7-sessionId=80q7V5stkK
}
```

## Account info

Requires authentication.

```sh
http GET en.l.org/account/info
```

Response: `200` OK
See `user` object in `Login` section, above.

## Logout

```sh
http GET en.l.org/logout
```

Response: `200` OK

# WEBSOCKET

## Unique `clientId`
Expand Down

0 comments on commit 93ea6b0

Please sign in to comment.