Ask coding questions

← Back to all posts
Repl AUTH
JBloves27 (1720)

Uh, so the title says all. Im making a flask website, but I'm trying to add repl auth or some kind of auth so only specific people can post and comment, etc. Could any of you guys put example auths in the comments? I'll attach repl if I have to. Another thing I should mention is that I'm using HTML and python.
Thanks! - JB

Answered by ch1ck3n (1630) [earned 5 cycles]
View Answer
Comments
hotnewtop
ch1ck3n (1630)

first put <script authed="location.reload()" src="https://auth.turbio.repl.co/script.js"></script> to where you want the auth button to be in your HTML.

and once authed it will reload the page and send headers. user-id, user-name, and user-roles.

	return render_template(
		'index.html',
		user_name=request.headers['X-Replit-User-Name']
	)

this will give the template context of what the username is.

	{% if user_name %}
	<h1>Hello, {{ user_name }}!</h1>
	{% else %}
	Hello! Please log in.
	<div>
		<script authed="location.reload()" src="https://auth.turbio.repl.co/script.js"></script>
	</div>
	{% endif %}
JBloves27 (1720)

thanks! ill let u know with the results (even tho ur in repl lol) @ch1ck3n