CSS selector and access control to hide User Id

31 views
Skip to first unread message

Kevin

unread,
Sep 3, 2011, 7:13:49 AM9/3/11
to Lift

I want to hide UserId from the user.

Currently, I have this

//--- snippet.scala
"a [href+]" #> (UserId.get.toString)

As an user clicks this link, it will direct to the user to a page
build by UserId. The UserId is used as a component of the href. This
is the unwanted UserId exposure and I don't want to use button. How to
hide UseId and achieve the described user case (e.g. a user clicks a
link or something (prefer no button) and directs the user to another
page and the page does not have an UserId and the page is generated by
request only)?

Thx,

K.

Viktor Hedefalk

unread,
Sep 3, 2011, 8:17:39 AM9/3/11
to lif...@googlegroups.com
Look at SHtml.link:

def link(to: String, func: () => Any, body: NodeSeq,
attrs: ElemAttr*): Elem = {
fmapFunc((a: List[String]) => {func(); true})(key =>
attrs.foldLeft(<a href={Helpers.appendFuncToURL(to, key +
"=_")}>{body}</a>)(_ % _))
}


So you can add a closure to the href that sets a RequestVar for instance.

If you want to bind with "a [href+]" you could probably do something like:

"a [href+]" #> (S.fmapFunc((a: List[String]) => {setYourUserIdHere;
true})(key => "?" + key + "=_"))

Dunno if there is something already made for that kind of thing…?

Thanks,
Viktor

> --
> You received this message because you are subscribed to the Google Groups "Lift" group.
> To post to this group, send email to lif...@googlegroups.com.
> To unsubscribe from this group, send email to liftweb+u...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/liftweb?hl=en.
>
>

Denis Nevmerzhitsky

unread,
Sep 3, 2011, 3:31:59 PM9/3/11
to lif...@googlegroups.com
Hi!

What about:
import http.js.JsCmds._
import http.js.JE._
...
"a [onclick]" #> (RedirectTo(someUrl) & JsReturn(JsFalse) toJsCmd)
// or more flexible
"a [onclick]" #> "window.location = this.href + %s;return false;".format(UserId.toString encJs)
// or even
def secureUserLink(userId:Int):String = "window.location = this.href + %s;return false;" format userId.toString.encJs
"a [onclick]" #> secureUserLink(UserId)

Kevin

unread,
Sep 3, 2011, 6:48:42 PM9/3/11
to Lift
Hi Denis,

Sew your other posts.
http://groups.google.com/group/liftweb/browse_thread/thread/8cad3ab57e09226e/3f6a3894e911e19a#3f6a3894e911e19a

So good to have you in Lift's community.

K.
P.S. And thanks Viktor.

On Sep 3, 12:31 pm, Denis Nevmerzhitsky <kastigars...@gmail.com>
wrote:
Reply all
Reply to author
Forward
0 new messages