Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Guest / No-login / read-only. #12

Open
RomeSilvanus opened this issue Jun 2, 2018 · 1 comment
Open

Guest / No-login / read-only. #12

RomeSilvanus opened this issue Jun 2, 2018 · 1 comment

Comments

@RomeSilvanus
Copy link

RomeSilvanus commented Jun 2, 2018

Since the original Dev has stated that there are no plans to integrate it I'm gonna ask here because you seem to put in new features.

Is there a way, or planned feature, that allow it to run without a user authentication?
Or is there a way to modify the files a bit to make it work this way?

In the sense of that you add music, but when you open the URL it will just display you with a read-only interface that you can use to play music. Without login, without playlist (or read-only playlists)?

I'd like to run it to share mainly fan-made music in a small group so the ability to have a guest-user without login would be very useful.

Not sure if the CMS-feature could be what I'm looking for.

@X-Ryl669
Copy link
Owner

X-Ryl669 commented Jun 7, 2018

It's perfectly possible to do that:

  1. Create a "guest" account (the name "guest" could be anything, you just need an account with limited priviledges) with password "whatyouwant"
  2. Make sure you can log with this account
  3. Enable the CMS mode (change the line to "USING_CMS = true;" in app.vue and re-run yarn to build the application)
  4. Change the code in loginRedir.php to something as simple as:
$username = "guest";
require __DIR__.'/bootstrap/autoload.php';
$app = require_once __DIR__.'/bootstrap/app.php';
$app->make('Illuminate\Contracts\Http\Kernel')
    ->handle(Illuminate\Http\Request::capture());
// An instance of the Laravel app should be now at your fingertip ;-)
$isAuthorized = Auth::check();
if (!$isAuthorized)
{
    // Find user with the given login
    $users = DB::table('users')->get();
    foreach ($users as $user)
    {
        if (strcasecmp($user->name, $username) == 0)
        {
                $auth = Auth::loginUsingId($user->id, true);
                Auth::setUser($auth);
                $jwToken = JWTAuth::fromUser($auth);
                break;
        }
    }
}
$isAuthorized = Auth::check();
if ($isAuthorized)
{   // Need to store the authentication token in the browser's localStorage, so yes, Javascript is required here.
    echo "<html><body></body><script>";
    echo "localStorage.setItem('jwt-token', JSON.stringify('".$jwToken."'));"; // Key is "jwt-token"
    echo "window.location.replace('/');";
    echo "</script></html>";
}
else echo "Something went wrong.";
  1. Point any browser to http://yoursite/loginRedir.php and you'll be connected to the instance without any password.

Please notice however that the guest user will have the rights you've given him, so be very strict with your allocations ;-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants