Check if user is logged from outside

(Martial) #1

I have a website and i need to know if user is logged to allow him some part of the website.

In the API the request

Allow you to retrieve data of the current user. I tried to use this url to get the information with jquery like :

<!DOCTYPE html>
<script src=""></script>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
  <title>JS Bin</title>
       $.get('', function( data ) {

CORS is enabled and i get 404 (Not Found)

How can i know if user is logged into the forum ?

(Rafael dos Santos Silva) #2


(Martial) #3

Can you explain ? Where i get the lib ?

(Rafael dos Santos Silva) #4

Discourse is a global variable, so you can use it anywhere.

So, you want to know if the user is logged on Discourse outside Discourse? Sorry misread you previously. This is harder.

Maybe using Discourse as an SSO provider?

(Martial) #5

Finally, from inside, where should i put Discourse.User.current() ?

(Rafael dos Santos Silva) #6

It’s a javascript variable. You can use inside script tags.