import { Strategy } from 'passport-steam';
import { PassportStrategy } from '@nestjs/passport';
import { Injectable } from '@nestjs/common';
import { Request, Response } from 'express';
@Injectable()
export class SteamStrategy extends PassportStrategy(Strategy) {
constructor() {
super({
returnURL: 'http://localhost:3000/api/auth/return',
apiKey: '',
passReqToCallback: true
});
}
authenticate(req: Request, res: Response, options?: any): void {
if (req.headers.referer) {
const subdomain = req.headers.referer.replace(/(^\w+:|^)\/\//, '').split(".")
if (subdomain && subdomain[0] != "www" && subdomain[0] != "localhost:3000") {
console.log(subdomain[0]);
// ideally set return url here
}
console.log(options);
}
super.authenticate(req, options);
}
validate(request, identifier, profile, done) {
//console.log(request.headers.subdomain);
const data = profile._json;
let steamProfile = {}
steamProfile["steamid"] = data.steamid;
steamProfile["avatarfull"] = data.avatarfull;
steamProfile["username"] = data.personaname;
request.session.steamprofile = steamProfile;
//console.log(request.query);
return "Success"
}
}```
How can I achieve a different return url based on if the subdomain variable is present? I tried setting it through headers but they don't seem to persist between authentication and validate, and if I set a session variable there it also doesn't seem to get saved
#dynamic return
6 messages · Page 1 of 1 (latest)