Advertisement
Guest User

Untitled

a guest
Apr 2nd, 2015
254
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Scala 0.98 KB | None | 0 0
  1.  
  2.  
  3. import com.ctilogic.cvd.acl.api.{AuthType, Credentials}
  4. import com.ctilogic.cvd.acl.api.CredentialsAPI.{RemoveCredentials, CreateEmailPasswordCredentials}
  5. import com.ctilogic.cvd.acl.api.REST.SetPasswordRequest
  6. import com.ctilogic.cvd.common.{HandleAccount, NodeRole, RestRequestProcessor}
  7. import com.ctilogic.cvd.common.messaging.{SuccessResponse, ErrorResponse}
  8.  
  9.  
  10.  
  11. class SetPasswordRequestProcessor extends RestRequestProcessor[SetPasswordRequest] with HandleAccount
  12. {
  13.     import context.become
  14.  
  15.     override def processRequest = {
  16.         case SetPasswordRequest(accountId, password) if accountId == account.id
  17.             tellService(NodeRole.ACL, RemoveCredentials(AuthType.EmailPassword, account.email))
  18.             become {
  19.                 case SuccessResponse.Ok
  20.                     tellService(NodeRole.ACL, CreateEmailPasswordCredentials(account.id, account.email, password))
  21.                     become {
  22.                         case r: Credentials ⇒ complete(SuccessResponse.Ok)
  23.                     }
  24.             }
  25.         case r ⇒ complete(ErrorResponse.Forbidden)
  26.     }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement