Skip to content
Sign upLog in
← Back to Community
Repl.it Authentication V2
Profile icon
hacker
has Hacker Plan
Coder100

Repl.it Authentication V2

So, my first tutorial v1 was pretty successful! I guess a lot of you like Express.js and it was even posted on the newsletter! Yay! This version comes back even better because we are going to use the ES6 of templating: mustache.js

TL;DR code and website

Introduction

I first used pug, but I found out it wasn't the best to use, I mean, who wants to do this?

script. // Bleah no formatting wah!

that's why I made the switch to mustache! It is similar to angular.js's template, which is good since I am familiar to that. One cool thing is that you can set up the engine to your own liking, so I made it render for all the .htm files! Now that's cool.

New updates

  • Added jsonstore.io game soo you can see how powerful repl.it's API is
  • Some more browser-based proofs! Just uncomment the code and hit ctrl+enter!
  • I made my own script for handling the repl.it API. Everything is sustainable now! Anyways, what makes my script better is that it is unopinionated like express and you can customize the iframe much better and have custom handlers and error handlers. Read the readme.md to get more information.

Tutorial

There isn't too much of a difference, I suggest you please look at the code: code and the original post

Deriving some important identities

This isn't trig class lol anyways uncomment line 57 to prove there are only 3 request headers (you could've just looked at the login prompt which told you what was going to be shared) and uncomment line 100 to prove that the headers are persistent. Suggest more proofs by commenting below ↓


PLEASE VOTE UP IF YOU LIKED THIS SHORT BUT HELPFUL TUTORIAL!

code and website with the original post.


Ping me with questions if you are confused!

Voters
Profile icon
KreatusPlays
Profile icon
darkdarcool
Profile icon
Spotandjake
Profile icon
Wilke000
Profile icon
pg-4919
Profile icon
sojs
Profile icon
ProgramerMov
Profile icon
Squirrel777
Profile icon
dabs364
Profile icon
Vandesm14
Comments
hotnewtop
Profile icon
bateli

is dis a scam

Profile icon
Coder100

r u a scam

@bateli

Profile icon
AgastyaSandhuja

is there a way to authenticate by opening a new window because there is a glitch on my computer (a mac) and maybe other MacBooks where it asks to log in instead of authorizing, and when I do log in, it just takes me to my repls in a new tab and the original login tab is the same

Profile icon
Coder100

yeah, that is a pretty bad glitch on ios ... this is a bug with repl.it

@AgastyaSandhuja

Profile icon
AgastyaSandhuja

mac os too

@Coder100

but I found a different tutorial with a change so it's ok

Profile icon
Coder100

yeah, try reporting it to bugs

@AgastyaSandhuja

Profile icon
AgastyaSandhuja

i did

@Coder100

it's a problem too because then I can't log in into the surviv game :-(

Profile icon
AgastyaSandhuja

speaking of which, could you change the authentication to new window to it to make it accessible to everyone

@AgastyaSandhuja

Profile icon
Coder100
Profile icon
AgastyaSandhuja

I mean for the surviv game, change the repl.it login to new window so all users can access it so the mac users (like me) who don't get to log in can

@Coder100

srry for being confusing if I am
let me put it in a small talk: surviv game repl auth new window pls

Profile icon
Coder100

what do you mean by new window?

@AgastyaSandhuja

Profile icon
AgastyaSandhuja

new tab; it'll open the auth in a new tab in the browser.

@Coder100

Profile icon
Coder100

oh ok
how would that make a difference?
Wouldn't it open a new new tab? lol

@AgastyaSandhuja

Profile icon
sojs

Where is that tutorial.... [email protected]

Profile icon
eco27

eRrOr

Profile icon
Coder100

What's the error?

@MrEconomical

Profile icon
eco27

@Coder100
EEK! There was an error! Oh no! The error was: TypeError: Cannot read property 'score' of null

Profile icon
Coder100

oh.... I'll check the db

@MrEconomical

Profile icon
Coder100

ok... seems like your account didn't get created

@Coder100

Profile icon
Coder100
// Let's check if the user has registered or not. if(data){ // If user exists // Do nothing return false; }else{ // Let's set up the user if he hasn't! store.write(username+"-"+id, { score: 0 }); }```most likely this part the if statement is always true or something @Coder100
Profile icon
Coder100

I'll test with my alt

@MrEconomical

Profile icon
eco27

@Coder100
rapid fire messaging on repl talk be like

Profile icon
Coder100
Profile icon
Coder100

Ok I see the error smh jsonstore is freaking out again uggggggggh I'll have to switch to axios );

@MrEconomical

Profile icon
eco27

@Coder100
axios is superior

Profile icon
Coder100

ikr idk why people say request is but like axios is so unopiniated

@MrEconomical

Profile icon
Coder100

lmao i made the script so quick im betting it wont work lol

@MrEconomical