I need to get the value from link and then add them to DB.
I am working with another developer who created an api as a bridge because he does not know Laravel. Here is the api http://laravel.io/bin/614Xv I am currently passing string valued data like so http://laravel.io/bin/wYry0 and passing the parameters $user, $name, $password through the route.
Here is my route
Route::get('/profile/activated/{user?}/{pass?}/{email?}', array(
'as' => 'invited-user-account-created-get',
'uses' => 'ProfileController#getCreateInvitedUser'
));
Here is my function:
public function getCreateInvitedUser($user=null, $password=null, $email=null) {
$user = Input::get('username', 'abcd');
$pass = Input::get('password', '1234');
$email = Input::get('email', 'asas#gam.com');
//insert $user array in database users table
$user = User::create(array(
'username' => $user,
'password' => $pass,
'email' => $email
));
}
The other developer is wanting me to set the input to the variables I get from the url link/profile/activated/user/pass/email
Maybe I am tired but I am not understanding what he wants me to do and how to grab the variables from the url. The whole reason in doing this is to instantly store the invited guest info in the database when they click the activation link so they do not have to sign up for an account later.
Your route has a problem
Use this instead
Route::get('/profile/activated/{user}/{pass}/{email}', array(
'as' => 'invited-user-account-created-get',
'uses' => 'ProfileController#getCreateInvitedUser'
));
But his idea is totally messed up! Passing password values through a URL, Who does that even?
You sound enlightened, please advise him to try a different approach in whatever thing he's trying to achieve.
Related
I have the following code
$api = new Dailymotion();
$api->setGrantType(
Dailymotion::GRANT_TYPE_PASSWORD,
$apiKey,
$apiSecret,
array(),
array(
'username' => $username, // don't forget to sanitize this,
'password' => $password, // never use POST variables this way
)
);
$store = $api->get(
'/playlist/'.$playlist_id.'/videos?limit=10&page='.$pageNumber,
array('fields' => array('id', 'title','owner','channel','url','private_id','poster','thumbnail_url','duration')));
Before 3 days this code It worked very fine fine, but now retrieves empty list for private videos from my list on dailyMotion?
Try to see if at least connection to your playlist exists by making a call like this with your own playlist id https://api.dailymotion.com/playlist/x3ecgj/videos?limit=1&page=1.
From your comment it seems, your playlist doesn't have any videos and it is clear now I hope. That is why you are getting back an empty list.
What i'm try to do: Then user registered on my website he's got a email with confirmation random code.
My controller looks like that:
$activation_code = str_random(40);
/*
* Register user.
*/
$user = Sentry::register([
'username' => Input::get('username'),
'email' => Input::get('email'),
'password' => Input::get('password'),
'language_id' => $language->id,
'activation_code' => $activation_code
]);
$user->slug = Str::slug($user->username);
$user->save();
But then i check databse, the activation_code cell is empty. What i'm doing wrong? Thanks for answers!
I assume you meant the activation column not table, check your fillable array and make sure its in there.
EDIT
Scratch that, it looks like like your auto activating the user, no activation code necessary in that case.
FIXED! Works fine with:
$activationCode = $user->getActivationCode();
Hello folks I am stuck.
I want to register a User in Laravel 4. Now the thing is, that I want to first grab the email and password and save them in the database. And in step 2 of the registration process, I want to grab all the other details like first and last name and so on.
The difficulty is, that everything should be under one route called signup, for example everything under http://example.org/signup
Another difficulty is, that I have to access the same route with the same methods (GET & POST) twice, because I once get and post the form for Email and Password, and then I get and post the First, Last and Company Name into the Database.
I came up with the following solution, to store everything into the session, because through the session I can access the variables. So whenever I access my UserController I check, if there is data in the session and if yes, redirect to form 2.
Here are all my files:
http://help.laravel.io/d4104cae42f9a2efe1466ce53d086826bc9f6d7f
My Get-Method from the UserController:
public function create()
{
if(Session::has('email')) {
return View::make('frontend.signup.step2');
}
else {
return View::make('frontend.signup.step1');
}
}
My Post-Method from the UserController:
public function store()
{
// If User has a email and password in the session from the first create-View
// his data should be stored and then he gets redirected to a new create-View
Session::flush();
Session::put('email', Input::get('email'));
Session::put('password', Input::get('password'));
if (Session::has('email')) {
try
{
// Let's register a user.
$user = Sentry::register(array(
'email' => Input::get('email'),
'password' => Input::get('password'),
));
// Let's get the activation code
$activationCode = $user->getActivationCode();
// Send activation code to the user so he can activate the account
// Save Email in Emaillist
Email::create(array(
'email' => Session::get('email')
));
// Redirect
return Redirect::action('UserController#create');
}
return Redirect::route('signup');
}
else {
return 'No Session here';
}
}
Here are my routes:
Route::get('signup', array('as' => 'signup', 'uses' => 'UserController#create'));
Route::post('signup', array('as' => 'signup', 'uses' => 'UserController#store'));
For some reason I believe that it gets unneccessary complicated and I believe that there must be another more simple and intuitiv way to solve this, instead with if statements and redirects to the same controller-method.
Nonetheless I came up with some other solutions, for example just using the "signup" as prefix, but I don't like it that way.
Route::group(array('prefix' => 'signup'), function()
{
Route::get('/', function(){
return 'Yeab bababy yea';
});
Route::get('step1', array('as' => 'signup.step1', 'uses' => 'UserController#getStep1'));
Route::post('step1', array('as' => 'signup.step1', 'uses' => 'UserController#postStep1'));
Route::get('step2', array('as' => 'signup.step2', 'uses' => 'UserController#postStep2'));
Route::post('step2', array('as' => 'signup.step2', 'uses' => 'UserController#postStep2'));
});
Is there any way of accomplishing the task while only using one route and without using clientside Javascript to store the variables in the database? (I am a unexperienced with ajax)
The Goal should be to catch the email and still stay on the same route, like those smart guys here for example:
https://www.crazyegg.com/signup
I hope there is a way. Thank you for your help Internet.
Kind regards,
George
P.S.
It's 1 am here in Germany, so don't be mad if I don't respond the next couple of hours to comments, because I am going to sleep now. Thank you very much.
I am working on Kohana PHP framework.
I want to show a 'username' instead of controller name in my URL.
For example,
username = james then how to show
http://localhost:3000/james
instead of
http://localhost:3000/scrapbook/index => ... localhost:3000/scrapbook
(controller: scrapbook, action: index)
in the url.
My bootstrap file have the entry for such types of url. If I manually write ..//localhost:3000/james, it takes me to the requested page.
//Viewing a user's profile or account details - user/action
Route::set('profile', '(<username>(/<action>(/<id>)))',
array(
'username' => '([A-Za-z0-9\-]+)'))
->defaults(array(
'controller' => 'scrapbook',
'action' => 'index'));
What I want is if I manually signin and go to scrapbook, my url should show 'username' and not the name of the controller. I will appreciate if anyone can guide me in this.
Thanks
When you complete your sign in action, you'll want to redirect the user to the desired URL using reverse routing:
// ...in your controller
function action_signin()
{
// ...sign in logic
$this->request->redirect(
Route::get('profile')->uri(array(
'username' => $username
))
);
}
$username will be whatever the username of the user of the logged in user is that just signed in.
I am editing a website which someone has made in CakePHP, but I don't have any previous experience in Cake. I'm reading the manual but finding it quite hard to understand so thought I would post a question on here to see if I can get any quick answers.
I think that this code is being used to display a login box, and you can only log in with username test and password 123123
var $components = array("Auth", "Acl");
function beforeFilter(){
$this->Security->loginOptions = array(
'type' => 'basic',
'realm' => 'Authenticate Emergency Response Center'
);
$this->Security->loginCredentials = array(
'test' => '123123'
);
$this->Security->requireLogin();
$this->_bindToSite();
parent::beforeFilter();
}
I want the log in box to appear still, but I want to fill the loginCredentials array automatically with information from the database. I have a table called 'operators' which contains the fields 'user_id' and 'password'.
Could someone tell me how I would alter the code above to allow any of the usernames/passwords stored in the operators table to log in?
Thanks for any help
Build an array from the database and set $this->Security->loginCredentials equal to your array.
You can leave most of the hard work up to CakePHP's Auth component, but if you want to use a model other than the default 'User', you'll just need to set this in beforeFilter(). The best place to do this is probably app_controller.php in your app\ directory.
function beforeFilter(){
$this->Auth->userModel = 'Operator';
$this->Auth->fields = array(
'username' => 'user_id',
'password' => 'password'
);
);