remember challenge setup

This commit is contained in:
Thibault Duplessis 2016-02-04 23:20:32 +07:00
parent a400acd9cb
commit 3c77f02354
2 changed files with 7 additions and 3 deletions

View file

@ -94,9 +94,10 @@ object Setup extends LilaController with TheftPrevention {
case _ => Left("no_sid")
},
destUser = destUser)
(Env.challenge.api create challenge) >> negotiate(
html = fuccess(Redirect(routes.Round.watcher(challenge.id, "white"))),
api = _ => Challenge showChallenge challenge)
env.processor.saveFriendConfig(config) >>
(Env.challenge.api create challenge) >> negotiate(
html = fuccess(Redirect(routes.Round.watcher(challenge.id, "white"))),
api = _ => Challenge showChallenge challenge)
}
}
)

View file

@ -62,6 +62,9 @@ private[setup] final class Processor(
}
}
def saveFriendConfig(config: FriendConfig)(implicit ctx: UserContext) =
saveConfig(_ withFriend config)
private def saveConfig(map: UserConfig => UserConfig)(implicit ctx: UserContext): Funit =
ctx.me.fold(AnonConfigRepo.update(ctx.req) _)(user => UserConfigRepo.update(user) _)(map)
}