Revert "require bot flag for bot:play oauth scope"

This reverts commit 321f41c391.
bot-api
Thibault Duplessis 2018-04-16 02:18:55 +02:00
parent 321f41c391
commit 71d2cdf46a
2 changed files with 11 additions and 18 deletions

View File

@ -19,20 +19,16 @@ object OAuthToken extends LilaController {
}
def create = Auth { implicit ctx => me =>
lila.user.UserRepo.isBot(me) map { isBot =>
Ok(html.oAuth.token.create(env.forms.token.create(isBot)))
}
Ok(html.oAuth.token.create(env.forms.token.create)).fuccess
}
def createApply = AuthBody { implicit ctx => me =>
implicit val req = ctx.body
lila.user.UserRepo.isBot(me) flatMap { isBot =>
env.forms.token.create(isBot).bindFromRequest.fold(
err => BadRequest(html.oAuth.token.create(err)).fuccess,
setup => env.tokenApi.create(setup make me) inject
Redirect(routes.OAuthToken.index)
)
}
env.forms.token.create.bindFromRequest.fold(
err => BadRequest(html.oAuth.token.create(err)).fuccess,
setup => env.tokenApi.create(setup make me) inject
Redirect(routes.OAuthToken.index)
)
}
def delete(id: String) = Auth { implicit ctx => me =>

View File

@ -7,20 +7,17 @@ import play.api.data.validation.Constraints._
object OAuthForm {
private def scopesField(isBot: Boolean) = list(nonEmptyText.verifying { scope =>
OAuthScope.byKey get scope exists {
case OAuthScope.Bot.Play => isBot
case _ => true
}
})
private val scopesField = list(nonEmptyText.verifying(OAuthScope.byKey.contains _))
object token {
def create(isBot: Boolean) = Form(mapping(
val form = Form(mapping(
"description" -> nonEmptyText(minLength = 3, maxLength = 140),
"scopes" -> scopesField(isBot)
"scopes" -> scopesField
)(Data.apply)(Data.unapply))
def create = form
case class Data(
description: String,
scopes: List[String]