Skip to content

Commit

Permalink
added some comments
Browse files Browse the repository at this point in the history
  • Loading branch information
hongwei1 committed Feb 19, 2018
1 parent 53f074c commit a3ef749
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 5 deletions.
11 changes: 9 additions & 2 deletions src/main/scala/code/model/BankingData.scala
Original file line number Diff line number Diff line change
Expand Up @@ -358,8 +358,15 @@ trait BankAccount extends MdcLoggable {
}
}

private def viewNotAllowed(view : View ) = Failure("user does not have access to the " + view.name + " view")

private def viewNotAllowed(view : View ) = Failure(s"${UserNoPermissionAccessView} Current VIEW_ID (${view.viewId.value})")

/**
*
* Check search for the bankaccount private views which the user have access to ++ public views.
* @param user a user
* @return a list of views, the user can access
*
*/
final def permittedViews(user: Box[User]) : List[View] = {
user match {
case Full(u) => u.permittedViews(this)
Expand Down
9 changes: 7 additions & 2 deletions src/main/scala/code/model/User.scala
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,14 @@ trait User {
Failure("user doesn't have access to any view that allows initiating transactions")
}
}



/**
* return all the views the user has the access to.
*/
def views: List[View]
/**
* Check the User have this `view` or not.
*/
def permittedView(v: View): Boolean =
views.contains(v)

Expand Down
3 changes: 2 additions & 1 deletion src/main/scala/code/model/dataAccess/view.scala
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ Berlin 13359, Germany
package code.model.dataAccess

import code.api.APIFailure
import code.api.util.ErrorMessages
import code.util.{AccountIdString, UUIDString}
import net.liftweb.common.{Box, Full}
import net.liftweb.mapper._
Expand Down Expand Up @@ -522,7 +523,7 @@ object ViewImpl extends ViewImpl with LongKeyedMetaMapper[ViewImpl]{

def find(viewUID : ViewIdBankIdAccountId) : Box[ViewImpl] = {
find(By(permalink_, viewUID.viewId.value) :: accountFilter(viewUID.bankId, viewUID.accountId): _*) ~>
APIFailure(s"View with permalink $viewId not found", 404)
APIFailure(s"${ErrorMessages.ViewNotFound}. Current ACCOUNT_ID(${viewUID.accountId.value}) and VIEW_ID (${viewUID.viewId.value})", 404)
//TODO: APIFailures with http response codes belong at a higher level in the code
}

Expand Down

0 comments on commit a3ef749

Please sign in to comment.