RichResult

pdi.jwt.JwtPlayImplicits.RichResult
implicit class RichResult(result: Result)(implicit conf: Configuration, clock: Clock)

By adding import pdi.jwt.*, you will implicitely add all those methods to Result allowing you to easily manipulate the JwtSession inside your Play application.

package controllers

import java.time.Clock
import play.api.*
import play.api.mvc.*
import pdi.jwt.*

object Application extends Controller {
 implicit val clock: Clock = Clock.systemUTC

 def login = Action { implicit request =>
   Ok.addingToJwtSession(("logged", true))
 }

 def logout = Action { implicit request =>
   Ok.withoutJwtSession
 }
}

Attributes

Graph
Supertypes
class Object
trait Matchable
class Any

Members list

Value members

Concrete methods

def addingToJwtSession(values: (String, String)*)(implicit request: RequestHeader): Result

Keep the current JwtSession and add some values in it, if a key is already defined, it will be overriden.

Keep the current JwtSession and add some values in it, if a key is already defined, it will be overriden.

Attributes

def addingToJwtSession[A : Writes](key: String, value: A)(implicit evidence$1: Writes[A], request: RequestHeader): Result

Keep the current JwtSession and add some values in it, if a key is already defined, it will be overriden.

Keep the current JwtSession and add some values in it, if a key is already defined, it will be overriden.

Attributes

def hasJwtHeader(implicit request: RequestHeader): Boolean

Check if the header for a JwtSession is present (first from the Result then from the RequestHeader)

Check if the header for a JwtSession is present (first from the Result then from the RequestHeader)

Attributes

Returns

a Boolean indicating the presence of a JWT header

def jwtSession(implicit request: RequestHeader): JwtSession

Retrieve the current JwtSession from the headers (first from the Result then from the RequestHeader), if none, create a new one.

Retrieve the current JwtSession from the headers (first from the Result then from the RequestHeader), if none, create a new one.

Attributes

Returns

the JwtSession inside the headers or a new one

def refreshJwtSession(implicit request: RequestHeader): Result

If the Play app has a session.maxAge config, it will extend the expiration of the JwtSession by that time, if not, it will do nothing.

If the Play app has a session.maxAge config, it will extend the expiration of the JwtSession by that time, if not, it will do nothing.

Attributes

Returns

the same Result with, eventually, a prolonged JwtSession

def removingFromJwtSession(keys: String*)(implicit request: RequestHeader): Result

Remove some keys from the current JwtSession

Remove some keys from the current JwtSession

Attributes

Override the current JwtSession with a new one

Override the current JwtSession with a new one

Attributes

def withJwtSession(session: JsObject): Result

Override the current JwtSession with a new one created from a JsObject

Override the current JwtSession with a new one created from a JsObject

Attributes

def withJwtSession(fields: (String, JsValueWrapper)*): Result

Override the current JwtSession with a new one created from a sequence of tuples

Override the current JwtSession with a new one created from a sequence of tuples

Attributes

Override the current JwtSession with a new empty one

Override the current JwtSession with a new empty one

Attributes

Remove the current JwtSession, which means removing the associated HTTP header

Remove the current JwtSession, which means removing the associated HTTP header

Attributes