Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is there a way to autorun an app made with Coder after auth? #96

Open
miniBloq opened this issue Jun 21, 2015 · 4 comments
Open

Is there a way to autorun an app made with Coder after auth? #96

miniBloq opened this issue Jun 21, 2015 · 4 comments

Comments

@miniBloq
Copy link

I would like to run one of my apps (made with Coder) after user's authentication on the auth screen. What should I modify? Thanks!

@jmstriegel
Copy link
Contributor

Interesting... well, you could actually edit the auth program itself, and have it forward to /app/your_app instead of the /app/coder. "auth" is a normal coder app (just like almost everything in coder), but it's hidden from view on the home screen.

After logging in, if you go to /app/editor/edit/auth, it should open the auth program for editing. Look in the node tab, somewhere around line 122, there's a method called exports.index_handler. Inside, you'll find a line that looks like:

res.redirect('/app/coder' + firstuse);

Comment that one out, copy it, and change it with your app id:

//res.redirect('/app/coder' + firstuse);
res.redirect('/app/your_app' + firstuse);

You'll want to tread lightly, obviously, because you wouldn't want to break how the auth program works and lock yourself out accidentally. :)

Once you've saved, you should be bounced to that url after logging in, instead of the /app/coder url.

@miniBloq
Copy link
Author

Hi! Thanks.

I tried it (in fact I have edited that file before posting my question, only that I did it with nano using SSH). Something seems to not be working, since I'm still redirected to coder. Now I went to https://10.0.0.7/app/editor/edit/auth, edited it in the Node tab and reseted the RasPi (just in case). Here is my code, maybe I'm still missing something (thanks again!):

exports.index_handler = function( req, res ) {

var firstuse = "?firstuse";
if ( typeof( req.param('firstuse') ) === 'undefined' ) {
    firstuse = "";
}

if ( !exports.isConfigured() ) {
    res.redirect('/app/auth/configure?firstuse');
} else if ( !exports.hasPassword() ) {
    res.redirect('/app/auth/addpassword?firstuse');
} else if ( !exports.isAuthenticated(req) ) {
    res.redirect('/app/auth/login' + firstuse);
} else {
    //res.redirect('/app/coder' + firstuse);
    res.redirect('/app/thingscoder_v0_52' + firstuse);
}

};

@jmstriegel
Copy link
Contributor

Oh right - this fixes half the problem (if you go to / and you are logged in, it should take you to your app now). The other half is the javascript handler for when the login button is clicked.

Look in the JS tab in the auth app. Around line 244 of the loginClick function, you'll see this:

window.location.href="/app/coder" + firstuse;

You'll just want to do the same thing with that one.

@miniBloq
Copy link
Author

Thank you! It worked!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants