Skip to content

Commit

Permalink
Admin Login perfectly implemented. Yay
Browse files Browse the repository at this point in the history
  • Loading branch information
SebastinSanty committed Jan 21, 2017
1 parent d267a72 commit 5c7af78
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 10 deletions.
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2016 Sebastin Santy
Copyright (c) 2016 OSD Labs

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "stretto",
"name": "encore",
"version": "0.0.5",
"main": "electron.js",
"private": true,
Expand Down
10 changes: 6 additions & 4 deletions routes/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,15 @@ exports.createRoutes = function(app_ref) {
app.get('/downloadplaylist/:id', downloadPlaylist);

//adds login facility
app.get('/admin',function (req,res) {
res.render('admin',{msg:req.flash('error')});
});
app.get('/admin',function (req,res) { res.render('admin',{ msg:req.flash('error'), log: req.user? true : false});});
//auth using passport
app.post('/admin', passport.authenticate('local', { failureRedirect: '/admin', failureFlash: true }), function(req, res) {
res.redirect('/');
});

app.post('/logout', function(req, res) {
req.session.destroy();
res.redirect('/');
});
// remote control commands
app.get('/command/:name/:command', remoteCommand);
app.io.route('player_page_connected', function(req) { req.socket.join('players'); });
Expand Down Expand Up @@ -126,6 +127,7 @@ function musicRoute(req, res) {
remote_name: req.params.name,
demo: config.demo,
user: user,
log: req.user? true : false,
});
};

Expand Down
7 changes: 6 additions & 1 deletion views/admin.html
Original file line number Diff line number Diff line change
Expand Up @@ -151,11 +151,16 @@ <h1>Login</h1>
<button>create</button>
<p class="message">Already registered? <a href="#">Sign In</a></p>
</form> -->
{% if log %}
<form action="/logout" method="post" class="login-form">
<button type="submit">Logout</button>
{% else %}
<form action="/admin" method="post" class="login-form">
<input type="text" placeholder="username" name="username" />
<input type="password" placeholder="password" name="password" />
<button type="submit">login</button>
<p class="message">Not registered? <a href="#">Create an account</a></p>
<!-- <p class="message">Not registered? <a href="#">Create an account</a></p> -->
{% endif %}
</form>
</div>
</div>
Expand Down
4 changes: 2 additions & 2 deletions views/base/main_base.html
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
{% if menu %}
<nav class="navbar navbar-inverse navbar-fixed-top" role="navigation">
<div class="navbar-header">
<a class="navbar-brand" href="#playlist/LIBRARY">OSDLabs</a>
<a class="navbar-brand" href="#playlist/LIBRARY">Encore</a>
<button class="navbar-toggle" type="button" data-toggle="collapse" data-target="#navbar-main">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
Expand All @@ -68,7 +68,7 @@
<li style="align-self: center;">
<a class="pointer" id="search-button"><i class="fa fa-search fa-lg"></i></a>
</li>
{% if !demo %}
{% if log %}
<li class='dropdown'>
<a class='pointer dropdown-toggle' data-toggle='dropdown'>Scan Library <span class="caret"></span></a>
<ul class='dropdown-menu' role='menu'>
Expand Down
8 changes: 7 additions & 1 deletion views/index.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
{% extends 'base/main_base.html' %} {% block title %}Music{% endblock %} {% block extra_nav %}
{% if !log %}
<li><a class='pointer'>OSDLabs</a></li>
{% endif %}
{% if log %}
<li class='dropdown'>
<a class='pointer dropdown-toggle' data-toggle='dropdown'>Fetch New Music <span class="caret"></span></a>
<ul class='dropdown-menu' role='menu'>
Expand All @@ -14,7 +18,9 @@
</li>
</ul>
</li>
{% if !demo %}
{% endif %}

{% if log %}
<li><a id='open_settings' class='pointer'><i class="fa fa-cog"></i> Settings</a></li>
{% endif %} {% endblock %} {% block content %}
<div id="wrapper" class="custom_scrollbar" tabindex="0">
Expand Down

1 comment on commit 5c7af78

@SebastinSanty
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addresses issue #9

Please sign in to comment.