From 6c186b9300c667b72c01e6bacde4061f8c9df3b4 Mon Sep 17 00:00:00 2001 From: harshnarang8 Date: Mon, 29 Aug 2016 14:18:16 +0530 Subject: [PATCH 1/9] Add basic login.html page without form --- Client/login.html | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 Client/login.html diff --git a/Client/login.html b/Client/login.html new file mode 100644 index 0000000..3c13651 --- /dev/null +++ b/Client/login.html @@ -0,0 +1,29 @@ + + + Login Page + + + + + + + + +
+
+
+
+
+
+
Login
+
+ Here comes the data +
+
+
+
+
+ + From 97d622adc51a1cb0ee400b2c2477617e7dd55dfd Mon Sep 17 00:00:00 2001 From: Kunal Kapila Date: Mon, 29 Aug 2016 00:17:38 +0530 Subject: [PATCH 2/9] Updated README --- README.md | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/README.md b/README.md index ebc8460..b08831a 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,26 @@ # TechTests + +## Important: + +A note to all the pools partipating in SourceCode, Takneek 2016: + +You may see the available milestones with their points in ISSUES +-> MILESTONES i.e. [Here](https://github.com/pclubiitk/TechTests/milestones) + +Please note that the milestones may be updated (adding clarifications, +increasing points on unsolved issues) without prior notification. +More milestones will be added to the list as the event progresses, so please +stay up to date. We will announce these updates on our IRC channel, details of +which have been mentioned below. + +For any doubts, you should make a github issue. You may also connect with us +at `#pclub-takneek16` or send a private message on IRC to `pallav`, `kunalkap` or `saksham`. +(although this is not recommended). You may email us at `pclubiitk@gmail.com`. +Trying any other means of communication would lead to negative points being +awarded to that pool. + +## Description + An online portal to conduct technical tests with a variety of problem types. This is a portal that can be used to conduct online tests on programming From 659869396e90ec89d8a59d52cfb914d52248b5b1 Mon Sep 17 00:00:00 2001 From: Pallav Agarwal Date: Mon, 29 Aug 2016 14:10:42 +0530 Subject: [PATCH 3/9] Update README.md --- README.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index b08831a..8e471dc 100644 --- a/README.md +++ b/README.md @@ -2,10 +2,11 @@ ## Important: -A note to all the pools partipating in SourceCode, Takneek 2016: +### A note to all the pools partipating in SourceCode, Takneek 2016: -You may see the available milestones with their points in ISSUES --> MILESTONES i.e. [Here](https://github.com/pclubiitk/TechTests/milestones) +### You may see the available milestones with their points in ISSUES -> MILESTONES i.e. [Here](https://github.com/pclubiitk/TechTests/milestones) + +### Press the watch button on the top to be notified of any changes to this repository! Please note that the milestones may be updated (adding clarifications, increasing points on unsolved issues) without prior notification. From 40a8376a2e97caf2a13892454598147da4125217 Mon Sep 17 00:00:00 2001 From: Pallav Agarwal Date: Mon, 29 Aug 2016 20:20:13 +0530 Subject: [PATCH 4/9] Update README.md --- README.md | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 8e471dc..a2fd5d8 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,17 @@ # TechTests -## Important: - -### A note to all the pools partipating in SourceCode, Takneek 2016: - -### You may see the available milestones with their points in ISSUES -> MILESTONES i.e. [Here](https://github.com/pclubiitk/TechTests/milestones) - -### Press the watch button on the top to be notified of any changes to this repository! +## Important: A note to all the pools partipating in SourceCode, Takneek 2016: +## Make sure you read this carefully before proceeding + +- You may see the available milestones with their points [Here](https://github.com/pclubiitk/TechTests/milestones) +- Contacting the coordinators may be done through IRC, via #pclub-takneek16 channel on freenode +- You can turn on notifications for this repository using the watch button on top +- After adding the pull request, commits for minor bug fixes/typos are OK, working on a feature after adding the pull request is not. +- If another person has already made a pull request for something that needs integration into your feature, merge his/her commit into yours and continue. Do not try to reinvent the wheel, even if the other person is from a different pool (you may end up losing your pull request and points due to this). +- We are using IRC and not slack because our aim is to help you learn what to expect when contributing to open source, and IRC is a lot more used with that (slack is NOT open source) +- You can only view IRC messages which are sent while you are logged in. Remember that. +- Any clarification about the milestones should be asked in GitHub issues, so that it may benefit everyone. Code plagiarism will be penalised. So make sure you inform the use of code from other sources. +- Upto 20% bonus marks may be given if documentation of the source code is included. The exact bonus marks will be decided on the basis of quality of documentation. Please note that the milestones may be updated (adding clarifications, increasing points on unsolved issues) without prior notification. From 8f128be481768fbcb674bb12522d8bc31a8360cc Mon Sep 17 00:00:00 2001 From: Yash Srivastav Date: Mon, 29 Aug 2016 02:34:27 +0530 Subject: [PATCH 5/9] Added iitk server login Summary: Uses ftp to verify user with iitk servers. Only the backend part. How to test: The complete login can be tested manually using `httpie`. Run `node app` and then test using the following commands: ``` http get "localhost:8000" http get "localhost:8000/profile" ``` ^ Will redirect to `/login` ``` http post "localhost:8000/login" email="gangadhar@iitk.ac.in" password="shaktimaan" ``` ^ If password is correct will redirect to `/profile` in the output ``` http post "localhost:8000/login" email="gangadhar@iitk.ac.in" password="batman" ``` ^ If password is wrong will redirect to `/login` Pool: ``` __ __ _ _ | \/ | __ _ _ __ __ _| |_| |__ __ _ ___ | |\/| |/ _` | '__/ _` | __| '_ \ / _` / __| | | | | (_| | | | (_| | |_| | | | (_| \__ \ |_| |_|\__,_|_| \__,_|\__|_| |_|\__,_|___/ ``` --- .gitignore | 1 + Server/app.js | 45 ++++++++++++++--------- Server/config.js | 3 ++ Server/controllers/login.js | 9 +++-- Server/models/user.js | 11 ++++++ Server/npm-debug.log | 45 ----------------------- Server/package.json | 16 +++++---- Server/passport.js | 72 ++++++++++++++++++++++++++++++++++--- Server/router.js | 30 ++++++++++++++-- 9 files changed, 156 insertions(+), 76 deletions(-) create mode 100644 .gitignore create mode 100644 Server/models/user.js delete mode 100644 Server/npm-debug.log diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..3c3629e --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +node_modules diff --git a/Server/app.js b/Server/app.js index e6b2b8e..c79bfa3 100644 --- a/Server/app.js +++ b/Server/app.js @@ -1,22 +1,33 @@ -var express = require('express'); -var path = require('path'); -var logger = require('morgan'); -var bodyParser = require('body-parser'); -var passport = require('passport'); -var session = require('express-session'); +var bodyParser = require('body-parser'); +var config = require('./config.js'); var cookieParser = require('cookie-parser'); -var config = require('./config.js'); -var winston = require('winston'); +var flash = require('connect-flash'); +var errorroutes = require('./router.js'); +var express = require('express'); +var logger = require('morgan'); +var mongoose = require('mongoose'); +var passport = require('passport'); +var path = require('path'); +var routes = require('./router.js'); +var session = require('express-session'); +var winston = require('winston'); +var app = express(); -var routes = require('./router.js'); -var errorroutes = require('./router.js'); -var __dirname = path.resolve(path.dirname()); -var app = express(); +// Connect to database +mongoose.connect(config.db.url); +// Serve static content +app.use('/', express.static(path.join(__dirname, '../Client/'))); + +// Load passport settings require('./passport')(passport); + +// Setup express app app.use(logger('short')); app.use(bodyParser.json()); -app.use(bodyParser.urlencoded({ extended: false })); +app.use(bodyParser.urlencoded({ + extended: false +})); app.use(cookieParser()); app.use(session({ secret: 'PclubIITK', @@ -25,18 +36,20 @@ app.use(session({ })); app.use(passport.initialize()); app.use(passport.session()); +app.use(flash()); +// Setup routes app.use('/', routes); +// Define 404 functions var error404 = function(req, res) { res.status(404).send('Route not found.'); } - app.get('*', error404); app.post('*', error404); -app.listen(config.web.port, config.web.host, function () { - winston.log('info', 'TechTest service listening at http://%s:%s', config.web.host, config.web.port); +app.listen(config.web.port, config.web.host, function() { + winston.log('info', 'TechTest service listening at http://%s:%s', config.web.host, config.web.port); }); module.exports = app; diff --git a/Server/config.js b/Server/config.js index 6e55f0b..4420c3c 100644 --- a/Server/config.js +++ b/Server/config.js @@ -5,8 +5,11 @@ var path = require('path'); var config = {}; config.web = {}; +config.db = {}; config.web.host = '0.0.0.0'; config.web.port = 8000; +config.db.url = 'mongodb://localhost/users' + module.exports = config; diff --git a/Server/controllers/login.js b/Server/controllers/login.js index 8dcc179..159548b 100644 --- a/Server/controllers/login.js +++ b/Server/controllers/login.js @@ -1,3 +1,8 @@ -exports.checkAuth = function(req, res) { - res.send("Not Implemented"); +exports.checkAuth = function(req, res, next) { + // if user is authenticated in the session, carry on + if (req.isAuthenticated()) + return next(); + + // if they aren't redirect them to the login page + res.redirect('/login'); } diff --git a/Server/models/user.js b/Server/models/user.js new file mode 100644 index 0000000..385e9c3 --- /dev/null +++ b/Server/models/user.js @@ -0,0 +1,11 @@ +var mongoose = require('mongoose'); + +// define the schema for our user model +var userSchema = mongoose.Schema({ + + username : String, + access : { type : String, default : 'user' } + +}); + +module.exports = mongoose.model('user', userSchema); diff --git a/Server/npm-debug.log b/Server/npm-debug.log deleted file mode 100644 index ca29dba..0000000 --- a/Server/npm-debug.log +++ /dev/null @@ -1,45 +0,0 @@ -0 info it worked if it ends with ok -1 verbose cli [ '/usr/bin/node', '/usr/bin/npm', 'start' ] -2 info using npm@3.8.3 -3 info using node@v5.10.1 -4 verbose run-script [ 'prestart', 'start', 'poststart' ] -5 info lifecycle TechTests@0.1.0~prestart: TechTests@0.1.0 -6 silly lifecycle TechTests@0.1.0~prestart: no script for prestart, continuing -7 info lifecycle TechTests@0.1.0~start: TechTests@0.1.0 -8 verbose lifecycle TechTests@0.1.0~start: unsafe-perm in lifecycle true -9 verbose lifecycle TechTests@0.1.0~start: PATH: /usr/lib64/node_modules/npm/bin/node-gyp-bin:/home/pallav/proj/TechTests/Server/node_modules/.bin:/usr/bin:/home/pallav/bin:/usr/local/bin:/usr/local/sbin:/usr/bin:/bin:/opt/bin:/usr/x86_64-pc-linux-gnu/gcc-bin/4.9.3:/usr/games/bin:/home/pallav/.GO/bin -10 verbose lifecycle TechTests@0.1.0~start: CWD: /home/pallav/proj/TechTests/Server -11 silly lifecycle TechTests@0.1.0~start: Args: [ '-c', 'node app.js' ] -12 silly lifecycle TechTests@0.1.0~start: Returned: code: 1 signal: null -13 info lifecycle TechTests@0.1.0~start: Failed to exec start script -14 verbose stack Error: TechTests@0.1.0 start: `node app.js` -14 verbose stack Exit status 1 -14 verbose stack at EventEmitter. (/usr/lib64/node_modules/npm/lib/utils/lifecycle.js:239:16) -14 verbose stack at emitTwo (events.js:100:13) -14 verbose stack at EventEmitter.emit (events.js:185:7) -14 verbose stack at ChildProcess. (/usr/lib64/node_modules/npm/lib/utils/spawn.js:24:14) -14 verbose stack at emitTwo (events.js:100:13) -14 verbose stack at ChildProcess.emit (events.js:185:7) -14 verbose stack at maybeClose (internal/child_process.js:850:16) -14 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:215:5) -15 verbose pkgid TechTests@0.1.0 -16 verbose cwd /home/pallav/proj/TechTests/Server -17 error Linux 4.1.15-gentoo-r1 -18 error argv "/usr/bin/node" "/usr/bin/npm" "start" -19 error node v5.10.1 -20 error npm v3.8.3 -21 error code ELIFECYCLE -22 error TechTests@0.1.0 start: `node app.js` -22 error Exit status 1 -23 error Failed at the TechTests@0.1.0 start script 'node app.js'. -23 error Make sure you have the latest version of node.js and npm installed. -23 error If you do, this is most likely a problem with the TechTests package, -23 error not with npm itself. -23 error Tell the author that this fails on your system: -23 error node app.js -23 error You can get information on how to open an issue for this project with: -23 error npm bugs TechTests -23 error Or if that isn't available, you can get their info via: -23 error npm owner ls TechTests -23 error There is likely additional logging output above. -24 verbose exit [ 1, true ] diff --git a/Server/package.json b/Server/package.json index e47deca..c7e7716 100644 --- a/Server/package.json +++ b/Server/package.json @@ -7,19 +7,23 @@ "npm": ">= 1.2.0" }, "dependencies": { - "express": "4.12.4", "body-parser": "1.13.1", + "connect-flash": "^0.1.1", "cookie-parser": "*", - "passport": "*", - "express-session": "*", "debug": "~2.2.0", + "eslint": "*", + "express": "4.12.4", + "express-session": "*", + "ftp": "^0.3.10", + "mongoose": "^4.5.10", "morgan": "~1.6.1", + "passport": "*", + "passport-local": "^1.0.0", "require-dir": "*", - "eslint": "*", "winston": "*" }, - "scripts":{ - "start": "node app.js" + "scripts": { + "start": "node app.js" }, "main": "app.js", "license": "GPLv3" diff --git a/Server/passport.js b/Server/passport.js index 57b09c1..3813687 100644 --- a/Server/passport.js +++ b/Server/passport.js @@ -1,15 +1,77 @@ -var model = {}; // Insert schema here -var localStrategy = require('passport-local').Strategy; +var LocalStrategy = require('passport-local').Strategy; + +// The user schema +var User = require('./models/user'); + +// For verifying via iitk servers +var Ftp = require('ftp'); + module.exports = function(passport) { - passport.serializeUser(...); - passport.serializeUser(...); - passport.use('local-signup', new LocalStrategy({ + + // Serializing using username + passport.serializeUser(function(user, done) { + done(null, user.username); + }); + + // Deserializing using username + passport.deserializeUser(function(id, done) { + User.findOne({ + 'username': id + }, function(err, user) { + done(err, user); + }); + }); + + // Definning a strategy for authentication and login + passport.use('local-signin', new LocalStrategy({ usernameField: 'email', passwordField: 'password', passReqToCallback: true }, function(req, email, password, done) { process.nextTick(function() { // Verify IITK login everytime, never save the password + if (email.match(/([A-Za-z0-9]+)@iitk\.ac\.in$/)) { + var login = new Ftp(); + var username = email.match(/([A-Za-z0-9]+)@iitk\.ac\.in$/)[1]; + login.on('ready', function() { + login.logout(); + login.destroy(); + User.findOne({ + 'username': username + }, function(err, user) { + if (err) + return done(err); + if (user) { + return done(null, user); + } else { + var newUser = new User(); + newUser.username = username; + newUser.save(function(err) { + if (err) + throw err; + return done(null, newUser); + }); + } + }); + }); + login.on('error', function(err) { + if(err.code == 530) { + login.destroy(); + return done(null, false, req.flash('loginmsg', 'Wrong Username or password')); + } else { + return done(err) + } + }); + var details = { + host: "webhome.cc.iitk.ac.in", + port: "21", + user: username, + password: password + }; + login.connect(details); + } else { + return done(null, false, req.flash('loginmsg', 'Not a valid iitk email id')); + } }); })); }; diff --git a/Server/router.js b/Server/router.js index 6e6e24c..53ab286 100644 --- a/Server/router.js +++ b/Server/router.js @@ -5,8 +5,34 @@ var config = require('./config.js'); var controllers = requireDir('./controllers'); var router = express.Router(); -// redirect. is retrieved from controllers/redirect.js +var passport = require('passport'); + +// Home Page router.get('/', controllers.redirect.loginRedirect); -router.post('/login', controllers.login.checkAuth); + +// Login Page +router.get('/login', function(req, res) { + // TODO: make a frontend and display req.flash('loginmsg') alongwith login form + res.send(req.flash('loginmsg')); +}); + +// Profile Page +router.get('/profile', controllers.login.checkAuth, function(req, res) { + // TODO: Redirect to profile page with user data + res.send( "Hello " + req.user.username ); +}); + +// Logout +router.get('/logout', function(req, res) { + req.logout(); + res.redirect('/'); +}); + +// Login Request +router.post('/login', passport.authenticate('local-signin', { + successRedirect : '/profile', // redirect to the secure profile section + failureRedirect : '/login', // redirect back to the signup page if there is an error + failureFlash : true + })); module.exports = router; From 81e0172fc9b18eb79cd6b2260717f47bdfcb5f54 Mon Sep 17 00:00:00 2001 From: Milind L Date: Mon, 29 Aug 2016 19:49:23 +0530 Subject: [PATCH 6/9] Add frontend for login using ejs Summary: Finished yashsriv's backend with an ejs based front-end (login page and a test profile page for a successful login). How to Test: In the Server directory: ``` node app ``` Then direct your browser to localhost:8000 and test it out. If password is correct, you're redirected to a test-profile page listing your access rights and username. If your input is incorrect, you will be directed again to the /login page, with a toast displaying what went wrong on the top right. Reason for Using EJS: I wanted a decent way to manage views as the content would change with the user. This seemed to be a quick and simple way to do that. Also, it looks quite neat. Pool: ``` __ __ _ _ | \/ | __ _ _ __ __ _| |_| |__ __ _ ___ | |\/| |/ _` | '__/ _` | __| '_ \ / _` / __| | | | | (_| | | | (_| | |_| | | | (_| \__ \ |_| |_|\__,_|_| \__,_|\__|_| |_|\__,_|___/ ``` --- Client/login.ejs | 55 +++++++++++++++++++++++++++++++++++++++++++++ Client/profile.ejs | 32 ++++++++++++++++++++++++++ Server/app.js | 3 ++- Server/package.json | 1 + Server/passport.js | 2 +- Server/router.js | 14 ++++++++---- 6 files changed, 101 insertions(+), 6 deletions(-) create mode 100644 Client/login.ejs create mode 100644 Client/profile.ejs diff --git a/Client/login.ejs b/Client/login.ejs new file mode 100644 index 0000000..060b34d --- /dev/null +++ b/Client/login.ejs @@ -0,0 +1,55 @@ + + + + + + + + + + + + + +
+
+ TechTests Login +
+
+
+
+
+ +
+
+
+
+ +
+
+
+
+ +
+
+
+
+ + + +
+ + diff --git a/Client/profile.ejs b/Client/profile.ejs new file mode 100644 index 0000000..2307df6 --- /dev/null +++ b/Client/profile.ejs @@ -0,0 +1,32 @@ + + + + + + + + + + + + + +
+
+ TechTests Profile +
+
+
Hello, <%= username %>!
+
You have <%= access %> access rights.
+
+ + +
+ + diff --git a/Server/app.js b/Server/app.js index c79bfa3..69cc6db 100644 --- a/Server/app.js +++ b/Server/app.js @@ -37,7 +37,8 @@ app.use(session({ app.use(passport.initialize()); app.use(passport.session()); app.use(flash()); - +app.set('view engine', 'ejs'); +app.set('views', __dirname + '/../Client/'); // Setup routes app.use('/', routes); diff --git a/Server/package.json b/Server/package.json index c7e7716..86e9704 100644 --- a/Server/package.json +++ b/Server/package.json @@ -11,6 +11,7 @@ "connect-flash": "^0.1.1", "cookie-parser": "*", "debug": "~2.2.0", + "ejs": "^2.5.1", "eslint": "*", "express": "4.12.4", "express-session": "*", diff --git a/Server/passport.js b/Server/passport.js index 3813687..385d131 100644 --- a/Server/passport.js +++ b/Server/passport.js @@ -22,7 +22,7 @@ module.exports = function(passport) { }); }); - // Definning a strategy for authentication and login + // Defining a strategy for authentication and login passport.use('local-signin', new LocalStrategy({ usernameField: 'email', passwordField: 'password', diff --git a/Server/router.js b/Server/router.js index 53ab286..63ad76c 100644 --- a/Server/router.js +++ b/Server/router.js @@ -12,14 +12,20 @@ router.get('/', controllers.redirect.loginRedirect); // Login Page router.get('/login', function(req, res) { - // TODO: make a frontend and display req.flash('loginmsg') alongwith login form - res.send(req.flash('loginmsg')); + var message = req.flash('loginmsg'); + if(message.length==0) message = ['']; + console.log(message); + res.render('login.ejs', { + message: message[0] + }); }); // Profile Page router.get('/profile', controllers.login.checkAuth, function(req, res) { - // TODO: Redirect to profile page with user data - res.send( "Hello " + req.user.username ); + res.render('profile.ejs', { + username: req.user.username, + access: req.user.access + }); }); // Logout From 0972243d0f0db4553c2d2b14e70cbc6f87eb125d Mon Sep 17 00:00:00 2001 From: Yash Srivastav Date: Mon, 29 Aug 2016 20:13:56 +0530 Subject: [PATCH 7/9] This is a combination of 7 commits. Revert "Add frontend for login using ejs" since it is redundant This reverts commit b043984d04db2ae0f3756e511b30a30128578541. It is redundant as @harshnarang8 already has contributed something. Add form to login.html add footer login.html add user.html basic update login form with error message update login.html page layout remove user.html empty file add id for inputCheckBox --- Client/login.ejs | 55 ------------------------------------ Client/login.html | 68 ++++++++++++++++++++++++++++++++++++++++++--- Client/profile.ejs | 32 --------------------- Server/app.js | 3 +- Server/package.json | 1 - Server/passport.js | 2 +- Server/router.js | 14 +++------- 7 files changed, 70 insertions(+), 105 deletions(-) delete mode 100644 Client/login.ejs delete mode 100644 Client/profile.ejs diff --git a/Client/login.ejs b/Client/login.ejs deleted file mode 100644 index 060b34d..0000000 --- a/Client/login.ejs +++ /dev/null @@ -1,55 +0,0 @@ - - - - - - - - - - - - - -
-
- TechTests Login -
-
-
-
-
- -
-
-
-
- -
-
-
-
- -
-
-
-
- - - -
- - diff --git a/Client/login.html b/Client/login.html index 3c13651..e3162c0 100644 --- a/Client/login.html +++ b/Client/login.html @@ -6,24 +6,84 @@ +
-
+
-
+
Login
- Here comes the data + +
+
+
+
+
+
diff --git a/Client/profile.ejs b/Client/profile.ejs deleted file mode 100644 index 2307df6..0000000 --- a/Client/profile.ejs +++ /dev/null @@ -1,32 +0,0 @@ - - - - - - - - - - - - - -
-
- TechTests Profile -
-
-
Hello, <%= username %>!
-
You have <%= access %> access rights.
-
- - -
- - diff --git a/Server/app.js b/Server/app.js index 69cc6db..c79bfa3 100644 --- a/Server/app.js +++ b/Server/app.js @@ -37,8 +37,7 @@ app.use(session({ app.use(passport.initialize()); app.use(passport.session()); app.use(flash()); -app.set('view engine', 'ejs'); -app.set('views', __dirname + '/../Client/'); + // Setup routes app.use('/', routes); diff --git a/Server/package.json b/Server/package.json index 86e9704..c7e7716 100644 --- a/Server/package.json +++ b/Server/package.json @@ -11,7 +11,6 @@ "connect-flash": "^0.1.1", "cookie-parser": "*", "debug": "~2.2.0", - "ejs": "^2.5.1", "eslint": "*", "express": "4.12.4", "express-session": "*", diff --git a/Server/passport.js b/Server/passport.js index 385d131..3813687 100644 --- a/Server/passport.js +++ b/Server/passport.js @@ -22,7 +22,7 @@ module.exports = function(passport) { }); }); - // Defining a strategy for authentication and login + // Definning a strategy for authentication and login passport.use('local-signin', new LocalStrategy({ usernameField: 'email', passwordField: 'password', diff --git a/Server/router.js b/Server/router.js index 63ad76c..53ab286 100644 --- a/Server/router.js +++ b/Server/router.js @@ -12,20 +12,14 @@ router.get('/', controllers.redirect.loginRedirect); // Login Page router.get('/login', function(req, res) { - var message = req.flash('loginmsg'); - if(message.length==0) message = ['']; - console.log(message); - res.render('login.ejs', { - message: message[0] - }); + // TODO: make a frontend and display req.flash('loginmsg') alongwith login form + res.send(req.flash('loginmsg')); }); // Profile Page router.get('/profile', controllers.login.checkAuth, function(req, res) { - res.render('profile.ejs', { - username: req.user.username, - access: req.user.access - }); + // TODO: Redirect to profile page with user data + res.send( "Hello " + req.user.username ); }); // Logout From 667b23118058ad7ef84f1af2708f940bf6e31687 Mon Sep 17 00:00:00 2001 From: harshnarang8 Date: Mon, 29 Aug 2016 18:39:38 +0530 Subject: [PATCH 8/9] add all basic user files merge login page commits update login.html page layout add id for inputCheckBox add id for inputCheckBox Wrapper added Halfway thro Revert "Halfway thro" This reverts commit 4dcf5068d0888a44c8a67a7e19b98cb1e0f52166. Worked on GUI --- Client/admin.html | 62 ++++++++++++++++++ Client/createTest.html | 103 +++++++++++++++++++++++++++++ Client/css/main.css | 15 +++++ Client/currentTest.html | 58 +++++++++++++++++ Client/js/include.js | 13 ++++ Client/js/main.js | 64 ++++++++++++++++++ Client/preferences.html | 54 ++++++++++++++++ Client/profile.html | 54 ++++++++++++++++ Client/results.html | 106 ++++++++++++++++++++++++++++++ Client/user.html | 79 ++++++++++++++++++++++ Server/.gitignore | 1 + Server/router.js | 3 +- Server/wrapper/.wrapper.go.swp | Bin 0 -> 12288 bytes Server/wrapper/README.md | 15 +++++ Server/wrapper/wrapper | Bin 0 -> 2772976 bytes Server/wrapper/wrapper.go | 115 +++++++++++++++++++++++++++++++++ 16 files changed, 740 insertions(+), 2 deletions(-) create mode 100644 Client/admin.html create mode 100644 Client/createTest.html create mode 100644 Client/css/main.css create mode 100644 Client/currentTest.html create mode 100644 Client/js/include.js create mode 100644 Client/js/main.js create mode 100644 Client/preferences.html create mode 100644 Client/profile.html create mode 100644 Client/results.html create mode 100644 Client/user.html create mode 100644 Server/.gitignore create mode 100644 Server/wrapper/.wrapper.go.swp create mode 100644 Server/wrapper/README.md create mode 100755 Server/wrapper/wrapper create mode 100644 Server/wrapper/wrapper.go diff --git a/Client/admin.html b/Client/admin.html new file mode 100644 index 0000000..dfe6205 --- /dev/null +++ b/Client/admin.html @@ -0,0 +1,62 @@ + + + Current Test + + + + + + + + + +
+ + + + diff --git a/Client/createTest.html b/Client/createTest.html new file mode 100644 index 0000000..d76e724 --- /dev/null +++ b/Client/createTest.html @@ -0,0 +1,103 @@ + + + Current Test + + + + + + + + + + + +
+
+ +
+

+

+

+
+
+
+
+
+
+
+
+ + +
+
+
+ +
+
+
+
+
+
+ Subjective Answer. +
+
+
+
+
+
+
+
+
+ +
+
+
+
+
+
+
+ +
+
+
+
+ +
+
+
+
+
+
+ + + diff --git a/Client/css/main.css b/Client/css/main.css new file mode 100644 index 0000000..9b6bb2f --- /dev/null +++ b/Client/css/main.css @@ -0,0 +1,15 @@ +body { + /* Margin bottom by footer height */ + margin-bottom: 60px; +} +.footer { + position: absolute; + bottom: 0; + width: 100%; + /* Set the fixed height of the footer here */ + height: 60px; + background-color: #f5f5f5; +} +.footer-para { + margin: 20px 0; +} diff --git a/Client/currentTest.html b/Client/currentTest.html new file mode 100644 index 0000000..f042c1c --- /dev/null +++ b/Client/currentTest.html @@ -0,0 +1,58 @@ + + + Current Test + + + + + + + + + +
+
+ +
+

Test name: Hello World

+

+ +

+
+ +
+ + + diff --git a/Client/js/include.js b/Client/js/include.js new file mode 100644 index 0000000..e9421c8 --- /dev/null +++ b/Client/js/include.js @@ -0,0 +1,13 @@ + +
+
+
+ diff --git a/Client/js/main.js b/Client/js/main.js new file mode 100644 index 0000000..beebe16 --- /dev/null +++ b/Client/js/main.js @@ -0,0 +1,64 @@ +var noOfOptions = 0; +var qnType = 0; +// zero represents para type +// one represents single choice type +// two repesents multi choice type +jQuery(document).ready(function($) { + $(".clickable-row").click(function() { + window.document.location = $(this).data("href"); + }); + $(".CreationNav").on('click',function(e) { + $(e.target).parent.addClass('active'); + }); +}); +jQuery(document).ready(function($) { + $("#btnAddOption").click(function() { + // adding an option + noOfOptions += 1; + var sa1 = $('
').addClass('row').attr('id','Opt'+noOfOptions).css({'margin-top':'15px'}); + var sa2 = $('
').addClass('col-sm-1').html(noOfOptions+'.'); + var sa3 = $('
').addClass('col-sm-9'); + var sa4 = $('').addClass('form-control').attr({placeholder:'Option',id:('currentInput'+noOfOptions),type:'text'}); + var sa5 = $('
').addClass('col-sm-1'); + var sa6 = $(' +
+
+ +
+
+ +
+
+
diff --git a/Client/js/main.js b/Client/js/main.js index beebe16..15ab078 100644 --- a/Client/js/main.js +++ b/Client/js/main.js @@ -1,8 +1,14 @@ var noOfOptions = 0; -var qnType = 0; +var qnType = 1; // zero represents para type // one represents single choice type // two repesents multi choice type +var Test = []; +var CurrentQuestion = { + qnText : "", + type : -1, + options : [] +}; jQuery(document).ready(function($) { $(".clickable-row").click(function() { window.document.location = $(this).data("href"); @@ -18,7 +24,7 @@ jQuery(document).ready(function($) { var sa1 = $('
').addClass('row').attr('id','Opt'+noOfOptions).css({'margin-top':'15px'}); var sa2 = $('
').addClass('col-sm-1').html(noOfOptions+'.'); var sa3 = $('
').addClass('col-sm-9'); - var sa4 = $('').addClass('form-control').attr({placeholder:'Option',id:('currentInput'+noOfOptions),type:'text'}); + var sa4 = $('').addClass('form-control optionInput').attr({placeholder:'Option',type:'text',value:''}); var sa5 = $('
').addClass('col-sm-1'); var sa6 = $('