I'm using the default Auth::routes() of Laravel.
Due of some customization, I need to change the redirectTo URL and the showLoginForm() as well as login() function.
What's the best way to do this without touching the files in the vendor/ directory? Extending?
Related
I am developing a project in Coldfusion with CFWheels MVC Framework with URL Rewriting enabled. It involves user registration and each user should be presented as username.domain.com instead of www.domain.com/users/username. Moreover once I am on username.domain.com all child pages should work as:
username.domain.com/page1
username.domain.com/page2
username.domain.com/search?k=xyz
... etc
which I am unable to achieve.
I have updated my DNS settings of the particular domain so that *.domain.com all point to the same host. What am I still doing? I found this configuration , but I have not figured out how to implement it.
Sorry this is more of an extended comment than an answer
The code has a name of coldfusion-subdomains.cfm but it looks like something that would go into application.cfc. If you look at https://github.com/cfmaniac/CF-SubDomains , it states
CF-Subdomains is a snippet of code (best used in your OnRequest Method of Application.cfc) to detect and include files from a subdirectory on your server and let it act like a subdomain.
So from here, I would go to the cfwheels documentation so see if it does anything special with OnRequest()
I don't see anything that wraps around OnRequest(), so maybe it can be used as is
You may also want to consider url re-writing instead
http://docs.cfwheels.org/docs/url-rewriting
In Rails 4 application I need to reload routes (routes.rb) for every request before the application uses it. Where should I put MyApplication::Application.reload_routes!
I have tried to put it in config/applicaion.rb,config/environments.rb but it's not working.
I have also tried to put it in before_filter of ApplicationController and it's also failing.
RoR api is brief on how to use it.
So any assistance/guidance on this will be greatly appreciated
Seriuosly i would never do that. It is massive intervention into Rails internals. Just configure one dynamic route to a single controller. Then load some Command(Service)
according to the dynamic part of the url from the db, deserialize, instantiate and pass
the current controller as a reference to this dynamic service constructor.
The dynamic service you are loading should be implemented according to the following refactoring technique:
Replace Method with Method Object
Another Option would be to load a lambda/Proc because it would automatically have the controller scope once instantiated
The goal
No log in screens!
A visitor to the site should be able to create a widget without logging in.
This widget is publically accessible and can be shared via a short URL.
To edit this widget, you need to know the longer, administration URL.
The show action should have a URL with a short token instead of an id:
widget_path(widget) # => /widget/abc123
The edit action should have a URL with a long token instead of an id:
widget_path(widget) # => /widget/abcdefghijklmnop123/edit
What I have so far:
Generating tokens
I'm using a before_create callback to generate two tokens, a token and an admin_token with SecureRandom.urlsafe_base64.
Then, to change the URL helpers from generating URLs with the id, I override the to_param method in the model to return the token:
def to_param
token
end
Now when I save a new record, a token gets generated and the url helpers return these:
widget_path(widget) # => /widget/abc123
edit_widget_path(widget) # => /widget/abc123/edit
The problem
I need the edit_widget_path helper to use the admin_token field.
I can't seem to find a way of doing this.
In an ideal solution, I would want the _url versions of these to also work and they should be available in the usual places (controllers and views).
The closest I have found is to create custom _path and _url methods in ApplicationController, but this doesn't seem right.
Open to suggestions for how to achieve this.
Is there a way to use Rails' existing mechanism for generating URL helpers?
I hope that makes sense, feel free to ask for clarification.
Thank you!
I don't know of any rails mechanism that could handle that except inheritance. You could implement a subclass and override the to_param method there. I don't think that this is worth doing so, since you just want to handle 1 route here. I think I would just create a helper method to handle that case.
Another hint here: You could use the same mechanism that GIT uses. Create a UUID (long version) and use the first X digits to make the public url, just the full UUID is secret. This works in GIT 99,9% of the time without collisions, so it should work for you as well.
I've been creating a theme for prestashop and found out pretty early on that you could override module templates by creating a folder in myTheme/modules/modulename and then put the overriding templates in there, however, when I try and do this for the paypal module the overriden template file does not get used.
Have any other prestashop users had this problem in the past and if so how have you fixed it? Thanks in advance.
I was having a similar problem because I was copying the files from modules I wanted to override into my theme directory and deleting those I wasn't overriding.
However, PayPal's module is several levels deep. You can't leave the files where they are, they need to be in the root of the override dir.
Para example, to override express_checkout_payment.tpl:
Copy /app/modules/paypal/views/templates/hook/express_checkout_payment.tpl
to /app/themes/han/modules/paypal/express_checkout_payment.tpl
I have the same problem and found a workaround on prestashop forums.
It implies to modify the paypal module code, it's not a perfect solution, but it works...
how can I use the controllers created at
/administrator/components/com_mycom/controllers/*
in
/components/com_mycom/mycom.php
In detail:
I have a »log« controller with an »add« method, and I would like to use this from the frontend. I one is not logged in in the backend the task is not executed and a 500 error rises. So just would like to include the backend controllerpath in the frontend, so that JController::getInstance( 'Mycom' ) still works.
Greetings…
EDIT:
After a long time of searching I could find a more or less undocumented Parameter of the:
JController::getInstance() method, namely the second one: $config = array(). Going through the source code I found out that there is one key of the »config-array« that is of interest, which is: »base_path«.
The call of:
JController:getInstance( 'Mycom, array('base_path' =>JPATH_ADMINISTRATOR.DS.'components'.DS.'com_mycom')' );
always delivers the backend controller and one can use them safely in the frontend, BUT one must take care that then also the views are taken from the backend side of the component. In my case, I just use it to make ajax-calls so it does not matter, but one needs to be careful with using this method when planning to create »frontend views« with »backend controller«.
Greetings…
I had recently a similar problem where I wanted to use the whole CRUD system form back-end also in front-end.
This is the method that worked for me (and I am not saying that this is recommended or best practice):
I've just modeled the folders / file structure from backend. PHP files contained something like:
require_once JPATH_ADMINISTRATOR . '/components/com_mycom/controllers/log.php';