Redirecting non-authorized access after login

381 views
Skip to first unread message

John C. Bland II

unread,
Aug 5, 2010, 5:37:40 PM8/5/10
to cfwh...@googlegroups.com
http://cli.gs/Eng8g 

I just blogged this and wanted to pass it along. I believe someone was discussing this recently so there could be other ways of doing this. I'd like to know others if so.

Thanks folks!

---
John C. Bland II
http://www.johncblandii.com
http://www.johnandseason.com
http://www.twitter.com/johncblandii
---
Suggested sites:
http://www.lifthimhigh.com - "Christian Products for Those Bold Enough to Wear Them"
http://www.sportsmatchmaker.com - "What are you doing today?"

raulriera

unread,
Aug 5, 2010, 7:15:31 PM8/5/10
to ColdFusion on Wheels
This is cool!

On Aug 5, 11:37 pm, "John C. Bland II" <johncblan...@gmail.com> wrote:
> http://cli.gs/Eng8g
>
> I just blogged this and wanted to pass it along. I believe someone was
> discussing this recently so there could be other ways of doing this. I'd
> like to know others if so.
>
> Thanks folks!
>
> ---
> John C. Bland IIhttp://www.johncblandii.comhttp://www.johnandseason.comhttp://www.twitter.com/johncblandii
> ---
> Suggested sites:http://www.lifthimhigh.com- "Christian Products for Those Bold Enough to
> Wear Them"http://www.sportsmatchmaker.com- "What are you doing today?"

Joey

unread,
Aug 5, 2010, 8:31:41 PM8/5/10
to ColdFusion on Wheels
booyah! should this be something added to the sample admin app?

On Aug 6, 9:15 am, raulriera <rierar...@gmail.com> wrote:
> This is cool!
>
> On Aug 5, 11:37 pm, "John C. Bland II" <johncblan...@gmail.com> wrote:
>
>
>
> >http://cli.gs/Eng8g
>
> > I just blogged this and wanted to pass it along. I believe someone was
> > discussing this recently so there could be other ways of doing this. I'd
> > like to know others if so.
>
> > Thanks folks!
>
> > ---
> > John C. Bland IIhttp://www.johncblandii.comhttp://www.johnandseason.comhttp://www.twi...

Chris Peters

unread,
Aug 5, 2010, 10:04:01 PM8/5/10
to cfwh...@googlegroups.com
In agreement on coolness. Thanks for taking the time to give us a shout-out on your blog, John. I hope you can write more in the future. :)


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


John C. Bland II

unread,
Aug 6, 2010, 2:36:02 AM8/6/10
to cfwh...@googlegroups.com

Thanks guys!

I'm Wheels'n regularly now so you can expect more writing.

--------------------------
John C. Bland II
Mobile

>> cfwheels+u...@googlegroups.com<cfwheels%2Bunsu...@googlegroups.com>

Joey

unread,
Aug 9, 2010, 2:10:29 AM8/9/10
to ColdFusion on Wheels
Hey John,

I was playing around with the code and modified it slightly for my
needs (using filters since Chris has persuaded me to use them more
often! haha). Works so well and I thought I'd share it to see if it
can do with more refinement. Thanks for the idea!


<cffunction name="init">
<cfset
filters(through="persistVariables",only="new,edit",type="after") />
</cffunction>

<cffunction name="persistVariables">
<cfset session.persistantvariables = StructCopy(params) />
</cffunction>


<cffunction name="update">
<cfscript>
//dump(session);
if(NOT StructKeyExists(params,"key"))
{
redirectTo(back=true);
}

LayoutListProperties =
model("LayoutListProperties").findByKey(params.key);

if (LayoutListProperties.update(params.LayoutListProperties)){
persistRedirectTo(action="index");
} else {
renderPage(action="edit");
}
</cfscript>
</cffunction>


<cffunction name="persistRedirectTo">
<cfset var args = {} />

<cfif isDefined("session.persistantVariables")>
<cfset args = StructCopy(session.persistantVariables) />
<cfelseif isDefined("arguments") AND IsStruct(arguments)>
<cfset args = StructCopy(arguments) />
<cfelse>
<cfset args.route = "home" />
</cfif>

<cfset StructDelete(session,"persistantVariables") />

<cfset redirectTo(argumentCollection=args) />
</cffunction>


On Aug 6, 4:36 pm, "John C. Bland II" <johncblan...@gmail.com> wrote:
> Thanks guys!
>
> I'm Wheels'n regularly now so you can expect more writing.
>
> --------------------------
> John C. Bland II
> Mobile
>
> On Aug 5, 2010 9:04 PM, "Chris Peters" <ch...@clearcrystalmedia.com> wrote:
>
>
>
> > In agreement on coolness. Thanks for taking the time to give us a
> shout-out
> > on your blog, John. I hope you can write more in the future. :)
>
> > On Thu, Aug 5, 2010 at 7:15 PM, raulriera <rierar...@gmail.com> wrote:
>
> >> This is cool!
>
> >> On Aug 5, 11:37 pm, "John C. Bland II" <johncblan...@gmail.com> wrote:
> >> >http://cli.gs/Eng8g
>
> >> > I just blogged this and wanted to pass it along. I believe someone was
> >> > discussing this recently so there could be other ways of doing this.
> I'd
> >> > like to know others if so.
>
> >> > Thanks folks!
>
> >> > ---
> >> > John C. Bland
> >> IIhttp://www.johncblandii.comhttp://www.johnandseason.comhttp://
> >>www.twitter.com/johncblandii
> >> > ---
> >> > Suggested sites:http://www.lifthimhigh.com-"Christian Products for
> >> Those Bold Enough to
> >> > Wear Them"http://www.sportsmatchmaker.com-"What are you doing today?"
>
> >> --
> >> You received this message because you are subscribed to the Google Groups
> >> "ColdFusion on Wheels" group.
> >> To post to this group, send email to cfwh...@googlegroups.com.
> >> To unsubscribe from this group, send email to
> >> cfwheels+u...@googlegroups.com<cfwheels%2Bunsubscribe@googlegroups.c om>
>
> <cfwheels%2Bunsu...@googlegroups.com<cfwheels%252Bunsubscribe@googlegro ups.com>
>
> >> .
> >> For more options, visit this group at
> >>http://groups.google.com/group/cfwheels?hl=en.
>
> > --
> > You received this message because you are subscribed to the Google Groups
>
> "ColdFusion on Wheels" group.> To post to this group, send email to cfwh...@googlegroups.com.
> > To unsubscribe from this group, send email to
>
> cfwheels+u...@googlegroups.com<cfwheels%2Bunsubscribe@googlegroups.c om>

John C. Bland II

unread,
Aug 10, 2010, 2:03:06 AM8/10/10
to cfwh...@googlegroups.com
Good deal Joey. The implementation looks solid.

I'll suggest a sidebar tweak:

 if (LayoutListProperties.update(params.LayoutListProperties)){

You should always make sure it is an object first. Wheels does not return an empty object or array/query so automatically treating it like one can cause a headache.

Change it to:
 if (isObject(LayoutListProperties) AND LayoutListProperties.update(params.LayoutListProperties)){

That should help. Other than that, looks solid!

---
John C. Bland II
http://www.johncblandii.com
http://www.lifthimhigh.com - "Christian Products for Those Bold Enough to Wear Them"
http://www.sportsmatchmaker.com - "What are you doing today?"


To unsubscribe from this group, send email to cfwheels+u...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages