Giter VIP home page Giter VIP logo

Comments (13)

binkabir avatar binkabir commented on June 12, 2024 6

Interestingly,
import pdi.jwt.JwtSession._
fixed the issue

from jwt-scala.

yahortsaryk avatar yahortsaryk commented on June 12, 2024 2

+1 Have the same issue in Intellij IDEA... The code compiles via command line by "sbt compile" but in IDE it throws compiling errors...

UPDATE: I fixed it by adding "JwtPlayImplicits" trait (https://github.com/pauldijou/jwt-scala/blob/master/play/src/main/scala/JwtPlayImplicits.scala) for actions and my project started to compile in IntelliJ IDEA also

from jwt-scala.

pauldijou avatar pauldijou commented on June 12, 2024 1

If using 0.12.x, that's because all implicits have been moved inside their respective object. See changelog

from jwt-scala.

pauldijou avatar pauldijou commented on June 12, 2024

Play 2.4? Compile time error? Did you checked the import to be sure to have all needed implicits in the scope? Try import pdi.jwt._.

from jwt-scala.

alex88 avatar alex88 commented on June 12, 2024

Yeah sorry, Play 2.4, compile time errors.

Btw I already had that, this is the file that gets that jwtSession error:

package controllers

import scala.concurrent.Future
import play.api.libs.concurrent.Execution.Implicits._

import play.api.mvc._
import play.api.mvc.Results._
import play.api.libs.json._

import pdi.jwt._

import models.User

class AuthenticatedRequest[A](val user: User, request: Request[A]) extends WrappedRequest[A](request)

trait Secured {
  def Authenticated = AuthenticatedAction
}

object AuthenticatedAction extends ActionBuilder[AuthenticatedRequest] {
  def invokeBlock[A](request: Request[A], block: AuthenticatedRequest[A] => Future[Result]) =
    request.jwtSession.getAs[User]("user") match {
      case Some(user) => block(new AuthenticatedRequest(user, request)).map(_.refreshJwtSession(request))
      case _ => Future.successful(Unauthorized)
    }
}

from jwt-scala.

pauldijou avatar pauldijou commented on June 12, 2024

By randomly, do you mean it works sometime? Your code looks just fine... not sure what I can do about potential SBT problems... There is no reason for code which compile not to compile anymore if nothing changed.

Did you tried to reproduce with the play-angular-standalone application inside this repo? You could downgrade it to Play 2.4 and JWT Scala 0.5.1 and try to add your own stuff until it breaks.

from jwt-scala.

alex88 avatar alex88 commented on June 12, 2024

I mean that sometimes it doesn't work on intellij startup, after one or two SBT refresh it works fine, And I'm having this issue since I've added jwt-play. I'll do that way when I've some free time, I'll close this for now. Thank you

from jwt-scala.

bennythomps avatar bennythomps commented on June 12, 2024

I'm still having this issue. It is indeed intermittent and it's not an issue with SBT compiling it's IntelliJ. It works when building with sbt command line, but not when built with IntelliJ. It must have something going on with implicits.

from jwt-scala.

petetnt avatar petetnt commented on June 12, 2024

I was having this issue with IntelliJ too, so I decided to test it out with Ensime on various other editors and the same issue persists and replicates on other IDEs and Text Editors (such as Atom).

Not really sure what is the issue here is either so I can't sadly help with that.

from jwt-scala.

pauldijou avatar pauldijou commented on June 12, 2024

But does the project compile and works fine using SBT cli?

from jwt-scala.

petetnt avatar petetnt commented on June 12, 2024

@pauldijou yeah, it compiles just fine and the example application does work.

from jwt-scala.

shafiquejamal avatar shafiquejamal commented on June 12, 2024

Hello, I'm having the same problem. My application compiles fine using SBT, but IntelliJ IDEA shows errors when calling the .jtwSession method on the request object.

This is also the case with the play-angular-standalone project. I downloaded this project and imported it into IntelliJ IDEA, and there too IDEA does not recognize the .jwtSession method on the request object, even thought SBT compiles and runs the project without problems.

Has anyone found a solution for this yet? Thanks,

from jwt-scala.

binkabir avatar binkabir commented on June 12, 2024

Hi @pauldijou Im having this same error with play 2.5.13.

from jwt-scala.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.