How can I use Replit auth to allow specific users only into website?

Is there a way to use Replit authentication to let specific users into my website, and other people would not be allowed into the website?

1 Like

You can use my template:
And use an IF statement that only lets certain people of see the page.


Not sure what language you’re using but I looked at your repls and it seems like you mostly make NodeJS Repls and Idk how ReplitAuth works with NodeJS sooo…

You could create an array of userids (or usernames, however userids never change unlike usernames) of people who are allowed to join. Then just check if the person on your site’s userid matches any of them in the array.

Here’s how I’d go about making this in Python Flask (using my pro template):

from flask import Flask, render_template, request, redirect

userids = [
	'17197014', # QwertyQwerty54
	# ...

host = ''
port = 3000
static_url_path = '/static/'

app = Flask(__name__, static_url_path=static_url_path)

def login():
	return render_template('login.html')

def index():
	userid = request.headers['X-Replit-User-Id']
	if not userid:
		return redirect('/login')
	if userid not in userids:
		return redirect('/cringe')
	return render_template('index.html')

def cringe():
	return render_template('cringe.html')

def page_not_found_error(e):
	return render_template('404.html'), 404

def internal_server_error(e):
	return render_template('500.html'), 500

if __name__ == '__main__':, port=port)

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.