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

OAuth Login #95

Open
wants to merge 34 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
29c5ccb
Merge pull request #15 from scorelab/develop
rhperera Jul 11, 2017
b2992a2
Merge pull request #16 from scorelab/develop
rhperera Jul 12, 2017
bfc8566
add pip install script to travis
rhperera Jul 12, 2017
fe60838
Merge branch 'develop'
rhperera Jul 12, 2017
82f4908
add pytest script
rhperera Jul 12, 2017
9d3a572
add py.test test script to travis
rhperera Jul 12, 2017
cf6601b
Update README.md
rhperera Jul 12, 2017
b6c25f8
Merge pull request #17 from rhperera/master
rhperera Jul 12, 2017
4c6620f
Update README.md
rhperera Jul 12, 2017
fb704cf
Merge branch 'develop'
rhperera Aug 8, 2017
5202a63
change travis build imaghe for master
rhperera Aug 8, 2017
313da6f
Fix a minor typo in README
malithsen Nov 26, 2017
b251e1c
Add a db dump
malithsen Nov 26, 2017
953a9e2
Update README - Eulogy to @hasa93
malithsen Nov 27, 2017
fca7bbd
Add CONTRIBUTORS.md
agentmilindu Nov 28, 2017
08bd9cc
Update CONTRIBUTORS.md
agentmilindu Nov 28, 2017
96fcb2f
add 2 tests
Phineas Dec 4, 2017
ca0d38a
fix codacy checks
Phineas Dec 4, 2017
9a7c216
Merge pull request #53 from Phineas/master
malithsen Dec 5, 2017
a12cb8b
Generate .gitignore using gitignore.io
emgaurv Dec 31, 2017
ef56a23
Update protractor.conf.js
iammosespaulr Jan 10, 2018
2a923ae
Add files via upload
iammosespaulr Jan 10, 2018
bbc2b03
Add files via upload
iammosespaulr Jan 11, 2018
4dd3367
Update app.e2e-spec.js
iammosespaulr Jan 11, 2018
70c0979
Update app.e2e-spec.js
iammosespaulr Jan 11, 2018
d63fdf3
Update README - Add About section.
ivantha Feb 27, 2018
3eca8e2
compile error fix
Sep 3, 2018
e7f5beb
oauth login: backend
Sep 8, 2018
ec9a5e9
OAuth backend done
Oct 1, 2018
6338612
refactor
Oct 1, 2018
4042669
conflicts
vibhorgupta-gh Oct 28, 2018
b3be28a
WIP
vibhorgupta-gh Oct 31, 2018
9e02058
WIP
vibhorgupta-gh Oct 31, 2018
3df56e8
conflicts resolved
vibhorgupta-gh Oct 31, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
178 changes: 162 additions & 16 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

# Created by https://www.gitignore.io/api/git,node,linux,python,angular,firebase
# Created by https://www.gitignore.io/api/node,python,angular,firebase

### Angular ###
## Angular ##
Expand Down Expand Up @@ -36,25 +36,168 @@ testem.log
.idea
**/node_modules/*
**/.firebaserc
### Git ###
*.orig
### Node ###
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage

# nyc test coverage
.nyc_output

# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt

### Linux ###
*~
# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# temporary files which can be created if a process still has a handle open of a deleted file
.fuse_hidden*
# Compiled binary addons (http://nodejs.org/api/addons.html)
build/Release

# KDE directory preferences
.directory
# Dependency directories
node_modules/
jspm_packages/

# Linux trash folder which might appear on any partition or disk
.Trash-*
# Typescript v1 declaration files
typings/

# .nfs files are created when an open file is removed but is still being accessed
.nfs*
# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variables file
.env


### Python ###
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
*.egg-info/
.installed.cfg
*.egg

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
.hypothesis/

# Translations
*.mo
*.pot

# Django stuff:
local_settings.py

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
target/

# Jupyter Notebook
.ipynb_checkpoints

# pyenv
.python-version

# celery beat schedule file
celerybeat-schedule

# SageMath parsed files
*.sage.py

# Environments
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/

### Node ###
# Logs
logs
*.log
Expand Down Expand Up @@ -227,9 +370,12 @@ dronesym-python/flask-api/pip-selfcheck.json
dronesym-frontend/src/environments/environment.ts
dronesym-node/db.js
dronesym-node/config/mongoconfig.js
dronesym-node/dronedb-213c3-firebase-adminsdk-7u7ke-14febae0d1.json
dronesym-node/config/credentials.js
dronesym-node/dronesym-5f7ef-firebase-adminsdk-ucw8h-ca27a44b1e.json

#py.test caches
dronesym-python/flask-api/tests/__pycache__

# End of https://www.gitignore.io/api/git,node,linux,python,angular,firebase
# End of https://www.gitignore.io/api/node,python,angular,firebase


4 changes: 4 additions & 0 deletions CONTRIBUTORS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
CONTRIBUTORS
============

- Milindu Sanoj Kumarage (agentmilindu)
9 changes: 6 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# DroneSym
[![Build Status](https://travis-ci.org/scorelab/DroneSym.svg?branch=develop)](https://travis-ci.org/scorelab/DroneSym)
[![Build Status](https://travis-ci.org/scorelab/DroneSym.svg?branch=master)](https://travis-ci.org/scorelab/DroneSym)

In memory of [Hasanga Somaratne](https://github.com/hasa93) - Brilliant engineer, caring brother, and most excellent friend. This project is dedicated to you

### About DroneSym
Dronesym is a platform enabling users to handle and track their drone fleets in real time. Users can have functionality to add new drones configure their flight paths and monitor their progress through a web dashboard.

### Setting Up the Project

Expand All @@ -17,8 +22,6 @@
5. Import the database with `mongorestore --db dronesym dronedb/dronesym`
6. Run `npm start` to start the Node server

**Note: Make sure you have an admin account in the database under user collection. (Refer the schema in Models folder)**


### Part 2 - Setting up Python environment

Expand Down
67 changes: 67 additions & 0 deletions dronesym-frontend/e2e/app.e2e-spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
describe('Login Check ', function() {
it('should display an error if the Login Credentials are incorrect', function() {

// Visit the login page
browser.get('http://localhost:4200/');
//incorrect username entry and password entry
element(by.id('username')).sendKeys('lollipop');
element(by.id('password')).sendKeys('lollipop');
//Find the submit button and click it
element(by.css('[class="waves-effect waves-light btn blue darken-3 col s4 offset-s4"]')).click();
//Check whether it has the same url
expect(browser.getCurrentUrl()).toEqual('http://localhost:4200/');
});
});
describe('Login Check ', function() {
it('should be able to login with default admin credentials', function() {
browser.get('http://localhost:4200/');
element(by.css('form>div:nth-of-type(1)>input')).click();
element(by.css('form>div:nth-of-type(1)>input')).clear().sendKeys('admin'); //use correct login credentials
element(by.css('form>div:nth-of-type(2)>input')).clear().sendKeys('admin');
element(by.css('button')).click(); //login button
});
});
describe('Nav Buttons Check', function() {
it('should check Navigation Buttons i.e Dashboard', function() {
element(by.css('nav>div>ul>li:nth-of-type(1)>a>i')).click(); // Click the Dashboard button
});
it('Should Create Test Drone Group', function() {
element(by.css('div:nth-of-type(4)>a')).click();
element(by.css('confirm-dialog>div:nth-of-type(1)>form>div:nth-of-type(1)>div>label')).click();
element(by.css('confirm-dialog>div:nth-of-type(1)>form>div:nth-of-type(1)>div>input')).click();
element(by.css('confirm-dialog>div:nth-of-type(1)>form>div:nth-of-type(1)>div>input')).clear().sendKeys('Test'); //add drone test
element(by.css('div:nth-of-type(4)>a:nth-of-type(1)')).click();
});
it('should click on manage drones and next click on manage users and create a test user', function() {
element(by.css('app-user-dashboard>ul:nth-of-type(1)>div:nth-of-type(2)>a:nth-of-type(2)>div')).click();
element(by.css('a:nth-of-type(3)>div')).click();
element(by.css('div:nth-of-type(4)>a')).click();
element(by.css('user-signup>div:nth-of-type(1)>div:nth-of-type(1)>div:nth-of-type(1)>form>div:nth-of-type(1)>input')).click(); //add user test
element(by.css('user-signup>div:nth-of-type(1)>div:nth-of-type(1)>div:nth-of-type(1)>form>div:nth-of-type(1)>input')).clear().sendKeys('test'); //add username test
element(by.css('div:nth-of-type(4)>input')).click();
element(by.css('div:nth-of-type(4)>input')).clear().sendKeys('test'); //add password test
element(by.css('div:nth-of-type(5)>label')).click();
element(by.css('div:nth-of-type(5)>input')).click();
element(by.css('div:nth-of-type(5)>input')).clear().sendKeys('test'); // add confirmation password test
element(by.css('button')).click();
});
it('should check Navigation Buttons i.e Map and also check map functionality i.e zoom in, out and also drop a test drone', function() {
it('Should change view to Map when clicked on map button', function() {
element(by.css('div:nth-of-type(36)>div')).click(); // click on map
element(by.css('app-user-view>nav:nth-of-type(1)>div>ul>li:nth-of-type(2)>a')).click(); //// Check all the map functionalities
element(by.css('div:nth-of-type(125)>div:nth-of-type(1)>a:nth-of-type(1)>i')).click();
});
it('Should zoom in and should zoom out when clicked on the respective buttons', function() {
element(by.css('button[aria-label="Zoom in"]>div>img')).click();
element(by.css('button[aria-label="Zoom out"]')).click();
});
it('Should Check the Drop Drone function by dropping a test drone', function() {
element(by.css('div:nth-of-type(125)>div:nth-of-type(1)>a:nth-of-type(1)>i')).click();
element(by.css('div:nth-of-type(126)>div>ul>li:nth-of-type(1)>a>i')).click();
element(by.css('div:nth-of-type(73)>div')).click();
element(by.css('input')).click(); // drop drone
element(by.css('input')).clear().sendKeys('test'); // dropping drone name test
element(by.css('confirm-dialog>div:nth-of-type(1)>div:nth-of-type(4)>a:nth-of-type(1)')).click();
});
});
});
2 changes: 1 addition & 1 deletion dronesym-frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"engines": {},
"private": true,
"dependencies": {
"@agm/core": "^1.0.0-beta.0",
"@agm/core": "^1.0.0-beta.2",
"@angular/animations": "^4.0.0",
"@angular/common": "^4.0.0",
"@angular/compiler": "^4.0.0",
Expand Down
8 changes: 4 additions & 4 deletions dronesym-frontend/protractor.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ const { SpecReporter } = require('jasmine-spec-reporter');
exports.config = {
allScriptsTimeout: 11000,
specs: [
'./e2e/**/*.e2e-spec.ts'
'./e2e/**/*.e2e-spec.js'
],
capabilities: {
'browserName': 'chrome'
},
capabilities: {
'browserName': 'firefox'
},
directConnect: true,
baseUrl: 'http://localhost:4200/',
framework: 'jasmine',
Expand Down
1 change: 0 additions & 1 deletion dronesym-frontend/src/app/login/login.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,4 @@ export class LoginComponent {
}
});
}

}
19 changes: 19 additions & 0 deletions dronesym-node/Models/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,25 @@ var mongoose = require('mongoose');
var bcrypt = require('bcrypt-nodejs');

var userSchema = mongoose.Schema({
github: {
id: { type: Number },
username: { type: String, default: '' },
email: { type: String, unique: true },
token: { type: String }
},
google: {
id: { type: Number },
username: { type: String, default: '' },
email: { type: String, unique: true },
token: { type: String }
},
facebook: {
id: { type: Number },
username: { type: Number, default: '' },
email: { type: String, unique: true },
authToken: { type: Number },
refreshToken: { type: Number }
},
uname: {
type: String,
required: true
Expand Down
35 changes: 35 additions & 0 deletions dronesym-node/Routers/authRouter.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
const router = require('express').Router()
const passport = require('../auth/passporthandler')
const creds = require('../config/credentials')

router.get('/facebook', passport.authenticate('facebook', {
session: false,
scope: creds.facebook.profileFields
}), function(req,res){
res.send(200)
})
router.get('/google', passport.authenticate('google', { session: false }))
router.get('/github', passport.authenticate('github', { session: false }))


router.get('/facebook/callback', passport.authenticate('facebook', {
scope: creds.facebook.profileFields,
failureRedirect: '/dronesym/api/node/user/login'
}), function (req,res){
res.redirect('/dronesym/api/node/user/role')
})

router.get('/google/callback', passport.authenticate('google', {
failureRedirect: '/dronesym/api/node/user/login'
}), function (req,res){
res.redirect('/dronesym/api/node/user/role')
})

router.get('/github/callback', passport.authenticate('github', {
failureRedirect: '/dronesym/api/node/user/login'
}), function (req,res){
res.redirect('/dronesym/api/node/user/role')
})

module.exports = router

Loading