How do I change the hard code user id into the authenticated user?

Related searches

In my controller I have the following code

    $assignents =Assign::whereHas('users', function ($q) {
        $q->where('user_id', 3); 
    })->get();

I would like to have the number 3 be the authenticated user who is logged in. How can I rewrite this code?

You can use the Auth facade to retrieve the authenticated user.

$assignents = Assign::whereHas('users', function ($q) {
    $q->where('user_id', Auth::user()->id); 
})->get();

Remember to post the things that you have tried. It makes it more comfortable for us to help you with your problem, rather than just doing the code for you. I suggest you read this section: How to Ask it is an excellent resource and helped me ask better questions when I first came to the site!

How to get current authenticated user � Issue #569 � strongloop , Basically how can I get user ID from any place in the code? It creates a hard to debug bug where Request A sees app.currentUser filled by You can give it a try by installing loopback from github master ( npm install strongloop/loopback ). Get the authenticated user in a remote method strongloop/loopback.io#240. This code is remarkably simple. We start by calling the Membership.ValidateUser method, passing in the supplied username and password. If that method returns true, then the user is signed into the site via the FormsAuthentication class's RedirectFromLoginPage method.

you can do this without Auth Facade

$assignents = Assign::whereHas('users', function ($q) {
    $q->where('user_id', auth()->user()->id); 
})->get();

or

$assignents = Assign::whereHas('users', function ($q) {
    $q->where('user_id', auth()->id()); 
})->get();

CWE-798: Use of Hard-coded Credentials (4.2), Any user of that program may be able to extract the password. Client-side 344, Use of Invariant Value in Dynamically Changing Context For inbound authentication: Rather than hard-code a default username and password, key, or other� The above block of code is not exactly, but essentially, what the IIdentity.GetUserId extension method does. If none of this works, then the user may not really be logged into your site yet. After logging in, you have to redirect to another page before the server will write the authentication cookie to the browser.

You can get authenticate user id by following ways:

Using auth() helper function

auth()->user()->id or auth()->id()

Using Auth Facade

Auth::user()->id, Auth::id()

Or you can get it by Request

public function index(Request $request)
{
    $request->user()->id;
}

Credentials Processes in Windows Authentication, In the case of a domain-joined computer, the authenticating target is the domain controller. Credentials are collected through user input on the logon user interface or The default set of providers can change with each version of the only to SYSTEM account processes, are stored on the hard disk drive. First, assign a new UID to user using the usermod command. Second, assign a new GID to group using the groupmod command. Finally, use the chown and chgrp commands to change old UID and GID respectively. You can automate this with the help of find command.

Configuring Authentication, Retrieve the user ID and its password to authenticate the user on connecting to the server. The Change Provider page requires you to enter valid OS credentials when you The code for performing these tasks is written in the WebFOCUS language as Note: After a change, a hard restart of the server must be done. When a user logs in, the context of the system on the network changes, and a new EAP authentication occurs, thereby changing the authentication on the port to a user-based authentication

Windows Domain Authentication, Windows domain authentication allows users to log in to SGD if they belong to Authentication tab, click the Change Secure Global Desktop Authentication button. logs in to SGD, they must use the format domain\username for their username. server is on a different subnet to the domain controller, you must hard code� Short answer is that you can't. To reset a user's domain password you / they would need to be connected to the domain, since the password is reset on the AD controller, not the local machine. Locally you just has a cached copy of it, but that's not the master copy of it (which is why you don't see the user listed as a local user on the machine).

1) On your phone, log out of iMessage (settings/messages/send and receive/ then select Apple ID and it should give you the option to logout) 2) Log back in to iMessage on phone phone using your new Apple ID account. 3) From your watch, do a hard reboot (by pushing in the crown and the other button at the same time)

Comments
  • Auth::user()->id; or Auth::id()