-
Notifications
You must be signed in to change notification settings - Fork 1
TunaAuth Class
Phaze edited this page Aug 2, 2023
·
1 revision
Note: This module is very api request heavy! This code alone uses 4 http requests to voicemods website
// Import TunaAPI and the TunaAuth modules
const { TunaAPI, TunaAuth } = require('./');
// Setup a pretty blank tuna api
let tuna = new TunaAPI();
tuna.on('login', async () => {
console.log('Logged in as ' + tuna.user.profile.username);
})
// Create a tuna auth object with the email in it.
let auth = new TunaAuth({ email: 'my-very-cool-email@phazed.xyz' });
auth.once('requestCode', () => {
console.log('Email send to ' + auth.email);
process.stdout.write('Enter email verification code: ');
// Open the stdin for reciving the verification code
process.stdin.once('data', ( chunk ) => {
// Remove the \r\n off the end (i think its just \n on linux but i haven't tested that yet)
let code = chunk.toString().replace('\r\n', '');
// Call voicemods api again to check if the token is invaild
auth.verifyCode(code)
.then(token => {
// Should probably store this token to save spamming voicemods api...
// Login to tuna!
tuna.login(token);
})
})
})
email
: String
verifyCode(code: String): Promise<String>
- Parse the recived code into the api and it returns a String with the token in it
Written by phaze