only POST /logout (with app BC)

pull/3520/head
Thibault Duplessis 2017-08-24 10:24:00 -05:00
parent fe79236096
commit 54b9349edf
4 changed files with 38 additions and 7 deletions

View File

@ -94,11 +94,23 @@ object Auth extends LilaController {
implicit val req = ctx.req
req.session get "sessionId" foreach lila.security.Store.delete
negotiate(
html = fuccess(Redirect(routes.Main.mobile)),
api = apiVersion => Ok(Json.obj("ok" -> true)).fuccess
html = Redirect(routes.Main.mobile).fuccess,
api = _ => Ok(Json.obj("ok" -> true)).fuccess
) map (_ withCookies LilaCookie.newSession)
}
// mobile app BC logout with GET
def logoutGet = Open { implicit ctx =>
implicit val req = ctx.req
negotiate(
html = notFound,
api = _ => {
req.session get "sessionId" foreach lila.security.Store.delete
Ok(Json.obj("ok" -> true)).withCookies(LilaCookie.newSession).fuccess
}
)
}
def signup = Open { implicit ctx =>
NoTor {
Ok(html.auth.signup(forms.signup.website, env.RecaptchaPublicKey)).fuccess

View File

@ -329,7 +329,8 @@ POST /translation/select controllers.I18n.select
# Authentication
GET /login controllers.Auth.login
POST /login controllers.Auth.authenticate
GET /logout controllers.Auth.logout
GET /logout controllers.Auth.logoutGet
POST /logout controllers.Auth.logout
GET /signup controllers.Auth.signup
POST /signup controllers.Auth.signupPost
GET /signup/check-your-email/:name controllers.Auth.checkYourEmail(name: String)

View File

@ -10,6 +10,7 @@
padding: 5px 0;
}
#dasher_app .links a,
#dasher_app .links button,
#dasher_app .subs .sub {
display: block;
padding: 5px 10px;
@ -17,11 +18,18 @@
white-space: nowrap;
}
#dasher_app .links a:hover,
#dasher_app .links button:hover,
#dasher_app .subs .sub:hover,
#dasher_app .langs form > *:hover {
background: #F0F0F0;
color: #444;
}
#dasher_app .links button {
width: 100%;
text-align: left;
border: 0;
background: none;
}
#dasher_app .subs {
border-top: 1px solid #ddd;
}
@ -400,12 +408,16 @@ body.dark #dasher_app .board .zoom {
}
body.dark #dasher_app .head,
body.dark #dasher_app .links a:hover,
body.dark #dasher_app .links button:hover,
body.dark #dasher_app .subs a:hover,
body.dark #dasher_app .langs form > *:hover,
body.dark #dasher_app .selector a:hover {
background: #3e3e3e;
color: #b0b0b0;
}
body.dark #dasher_app .links button {
color: #8f8f8f;
}
body.dark #dasher_app .selector a:hover::before {
color: #555;
}

View File

@ -31,10 +31,16 @@ export default function(ctrl: DasherCtrl): VNode {
linkCfg('/coach/edit', ':'),
'Coach manager'),
h(
'a.text',
linkCfg('/logout', 'w'),
noarg('logOut'))
h('form', {
attrs: { method: 'post', action: '/logout' }
}, [
h('button.text', {
attrs: {
type: 'submit',
'data-icon': 'w'
}
}, noarg('logOut'))
])
]) : null;
}