Testing in Laravel 5.5 - testing

I want to test the user login without using dusk.
My problem is that I want to test the html form with the email and password fields, then complete those fields and if the login was correct, show the home route for example.
In previous versions we made this:
$this->type('email', 'example#gmail.com);
$this->type('password', '123456');
Now, I dont know how to do it.
$this->actingAs($user); //USUARIO CREADO ANTERIORMENTE
$response = $this->get(route('home'));
$response->assertStatus(200)
$response->assertViewIs('home');
The check I can do is that a logged-in user can go to the home path, but not when filling in the forms fields.

Related

How to make ProfileViews count in laravel?

I need help. How do I create profile visitors in Laravel 8? I have not written the code yet and I do not even have an idea how to complete this task. I would be very grateful if you could help me.
You can leave the visitor without any profile. He will be able to access public web pages without authentication and therefore only logged in users will have profile.
UPDATE
Proposed skeleton in two steps using cookies
1- When a user make request on profile page generate an unique identifier and store it in user cookie with a long enough validity if it not yet exists
2- Using this unique token register a new view count (if not yet done) before sending response to user.
use Illuminate\Support\Str;
use Illuminate\Http\Request;
use Illuminate\Http\Response;
use App\Http\Requests;
use App\Http\Controllers\Controller;
public function getProfilePage(Request $request){
if(!Cookie::has('uniqueId')){
$uniqueId = Str::uuid(); // generate unique id for current user
Cookie::queue('uniqueId', $uniqueId, [live time in minutes]);
// save it using Cookie::queue
// one year for example as live time
}
// check if view count already exists for $uniqueId
// and save it in a persistent way if not
// other stuff ....
return ....
}

How to modify laravel 5.6 login behaviour? How to add more fields for logging along with email and password?

Laravel has 2 fields in its auth to help user login i.e email and password. I have added another field(hidden field) in the login blade to pass a random number along with a password and email.
In my eloquentuserprovider.php i am grabbing $credentials[‘password’] and $credentials[‘email’] like this but when I write $credentials[‘hidden’] I get an error saying ‘undefined index hidden’.
So my question is how should I add other fields along with email and password to validate the user
I am writing all my validation logic in eloquentuserprovider.php

How to get user information from hippo via HST

I'm evaluating the hippo cms,
after add hst-security as a dependence ,so public site need login, but how can I fetch the login user's detail information like email and something else.
I used HstRequest.getUserPrincipal ,but only get the username.
and tried to write a query "SELECT_USER_QUERY = "SELECT * FROM hipposys:user"
but only get a user 'liveuser', after login with admin.
so , Anyone can help me ,how can I get the detail info?
You can do this:
final User user = JcrSessionUtils.getHippoSession(request.getRequestContext().getSession()).getUser();
user.getEmail();
user.getLastLogin()

Apex - passing a variable from one page to another

I have a form on one page which prompts a user to enter their email address. When they click "next" I want Apex to redirect the user to a different page which shows them a report which selects the records from the users table where the email address matches the one that they entered.
E.g.
SELECT *
FROM USERS
WHERE EMAIL_ADDRESS = (the email address that they entered on the previous page);
Can someone please explain the easiest way to do this?
I have only in the last 5 seconds heard about 'Apex' Lol ... But I think I found what you need to do.
You need to define a 'Branch' which will allow you to POST to whichever page you need to.
Here's some documentation on 'Branches': http://docs.oracle.com/cd/B32472_01/doc/appdev.300/b32469/pdf_report.htm#BABICIJG
Also this snipet may help:
It's [The 'branch'] in the middle (page processing section) of the
development page at the bottom. The branch will be executed whenever a
post submission occurs but you can put conditions on the branch.
Which I found at: http://dbaforums.org/oracle/index.php?showtopic=8139
The "Next" button should not redirect but should submit. The value of the page item has to be pushed to the session state for it to be available in the (apex) session. On submit you can then define a branch which will take you to the page with your report. Your report can then reference the page item by using bind variable notation in the region source:
SELECT * FROM USERS WHERE EMAIL_ADDRESS = :Px_EMAIL_ADDRESS

MVC user's full name in Url, how to handle duplicates

I want to setup the following url in my MVC4 website, using the user's full name in the url:
http://www.myapp.com/profile/steve-jones
I have setup the following route in Global.asax:
routeCollection.MapRoute(
"profile", "profile/{userName}",
new { controller = "myController", action = "profile", userName = string.Empty
});
And I can take the parameter 'steve-jones' and match it to a user with matching name. My only problem though is, what if there is more than one 'Steve Jones', how can I handle this?
Does anyone know of a workaround/solution to this so that I can use a user's full name as part of the url and still be able to retrieve the correct user in the controller method?
Am I forced into including the user's id with the url (something that I do not want to appear)?
The usual way of handling this is by appending a number when creating the profiles. So if "steve-jones" is already a name in the database, then make the user's display name "steve-jones2". You basically have to insist that all profile urls are unique, which includes updating any existing database and account creation code.
Alternatively (and/or additionally), if two same names are found then have the script reroute to a disambiguation page where the user is presented with links and snippet of profile info of the many existing Steve Joneseses so they can go to the full correct profile.
Another way of handling it is by giving all user profiles an additional numeric code on the end. At my university all logins are based on name, so they give everyone pseudo-random 3-digit extensions so that they are safe as long as they don't get 1000 people with the exact same names :)
Some people might be happier being steve-jones-342 if there is no steve-jones or steve-jones1, if you're concerned.