0

I have created sample seed project with help of existing activator seed samples.

Project basically does User/Password authentication with role based authorization. You can find full source code at https://github.com/pariksheet/dribble.

Technologies:

  1. Play 2.5.3
  2. play-silhouette 4.0.0
  3. play2-reactivemongo 0.11.14
  4. play-mailer 5.0.5
  5. Scala 2.11
  6. Mongo 3.2

Though this code works perfectly, I am not able to use latest features of play/silhouette/mongo. I have few doubts on using those.

Question 1: silhouette

In Module.scala:

Environment[JWTEnv](
  identityService,
  authenticatorService,
  Seq(),
  eventBus
)

Here, how to pass Credential Provider Object in Seq()? As, I am not able to figure out the solution. I am injecting Credential Provider in my all controller classes.

Question 2: ReactiveMongo:

In my UserDao.scala I am using old mongo api to get collection object:

val users = reactiveMongoApi.db.collection[JSONCollection]("users")

Code throws warning:

method db in trait ReactiveMongoApi is deprecated: Use [[database]]

How to use database method? I can see another thread How to setup Play!2.5 with ReactiveMongo, but it does not have a solution.

Question 3: mailer

I am using below config to send email through play app:

smtp.mock=false
smtp {
        host="smtp.mail.yahoo.com"
        port="465"
        ssl=true
        user="pari.test@yahoo.com"
        password="XXXXXXXXXXX"
        from="pari.test@yahoo.com"
}

Code works all good. However, I am getting warning:

smtp is deprecated, use play.mailer instead.

When I use play.mailer configs code fails. Play Mailer plugin with Play 2.5

Question 4: form

How to add validation in play form?

@(tokenId: String, form: Form[ResetPassword])(implicit messages: play.api.i18n.Messages, request: RequestHeader)
@main("Reset Password") {
  @helper.form(routes.Application.handleResetPassword(tokenId)) {

    @helper.inputText(form("password1"))

    @helper.inputText(form("password2"))

    <button type="submit">Submit</button>

  }

}

In above form, I would like to add validation that will check if password1 and password2 are same or not.

Community
  • 1
  • 1
Pari
  • 1,443
  • 3
  • 19
  • 34
  • Q2. As indicated in the depreciation warning, you should you `reactiveMongoApi.database` instead of the deprecated `.db`. You could have a look a the ReactiveMongo MailingList to see the discussion about this change. – cchantep Aug 29 '16 at 00:06
  • Meta: looks like Stackoverflow prefers that you split your post into multiple questions: http://meta.stackexchange.com/questions/39223/one-post-with-multiple-questions-or-multiple-posts – marcospereira Aug 29 '16 at 04:42
  • Thanks marcospereira. Let me split this question into four. – Pari Aug 29 '16 at 08:25
  • Added separate questions – Pari Aug 29 '16 at 10:33
  • Q1 - http://stackoverflow.com/questions/38949447/play-2-5-with-silhouette-4-0-credential-provider – Pari Aug 29 '16 at 10:33
  • Q2 - Answered - http://stackoverflow.com/questions/37444605/how-to-setup-play2-5-with-reactivemongo - – Pari Aug 29 '16 at 10:34
  • Q3 - http://stackoverflow.com/questions/39204037/play-2-5-with-mailer-plugin – Pari Aug 29 '16 at 10:34
  • Q4 - Answered - http://stackoverflow.com/questions/39203521/play-form-verification – Pari Aug 29 '16 at 10:35

0 Answers0