mirror of
https://github.com/Foltik/Shimapan
synced 2024-11-28 05:26:44 -05:00
Add login page
This commit is contained in:
parent
e6a09bbe40
commit
616b12d55a
@ -3,6 +3,7 @@ var upload = require('./routes/upload.js');
|
||||
var view = require('./routes/view.js');
|
||||
var auth = require('./routes/auth.js');
|
||||
var register = require('./routes/register.js');
|
||||
var login = require('./routes/login.js');
|
||||
|
||||
var fs = require('fs');
|
||||
var path = require('path');
|
||||
@ -18,6 +19,7 @@ module.exports = function(app) {
|
||||
app.use('/upload', upload);
|
||||
app.use('/api/auth', auth);
|
||||
app.use('/register', register);
|
||||
app.use('/login', login);
|
||||
|
||||
app.use(function(err, req, res, next) {
|
||||
if (err.name === 'UnauthorizedError') {
|
||||
|
9
app/routes/login.js
Normal file
9
app/routes/login.js
Normal file
@ -0,0 +1,9 @@
|
||||
var express = require('express');
|
||||
var router = express.Router();
|
||||
var path = require('path');
|
||||
|
||||
router.get('/', function(req, res, next) {
|
||||
res.sendFile(path.join(__dirname, '../../public/views', 'login.html'));
|
||||
});
|
||||
|
||||
module.exports = router;
|
@ -1 +1 @@
|
||||
angular.module('shimapan', ['ngFileUpload', 'ngclipboard', 'UploadComp', 'RegisterComp']);
|
||||
angular.module('shimapan', ['ngFileUpload', 'ngclipboard', 'UploadComp', 'RegisterComp', 'LoginComp']);
|
15
public/js/components/LoginComp.js
Normal file
15
public/js/components/LoginComp.js
Normal file
@ -0,0 +1,15 @@
|
||||
function LoginController($scope, AuthService) {
|
||||
$scope.login = function() {
|
||||
AuthService.login({
|
||||
username: $scope.username,
|
||||
password: $scope.password
|
||||
}).then(function() {
|
||||
alert('Logged In');
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
angular.module('LoginComp', ['AuthSvc']).component('loginComponent', {
|
||||
templateUrl: '/views/login-form.html',
|
||||
controller: LoginController
|
||||
});
|
@ -12,6 +12,5 @@ function RegisterController($scope, AuthService) {
|
||||
|
||||
angular.module('RegisterComp', ['AuthSvc']).component('registerComponent', {
|
||||
templateUrl: '/views/register-form.html',
|
||||
controller: RegisterController,
|
||||
controllerAs: 'vm'
|
||||
controller: RegisterController
|
||||
});
|
@ -22,7 +22,7 @@ angular.module('AuthSvc', []).service('AuthService', ['$http', '$window', functi
|
||||
return $http({
|
||||
method: 'POST',
|
||||
url: '/api/auth/login',
|
||||
headers: {'Content-Type': 'x-www-form-urlencoded'},
|
||||
headers: {'Content-Type': 'application/x-www-form-urlencoded'},
|
||||
transformRequest: function(obj) {
|
||||
var str = [];
|
||||
for (var p in obj)
|
||||
|
@ -16,6 +16,7 @@
|
||||
|
||||
<script src="/js/components/UploadComp.js"></script>
|
||||
<script src="/js/components/RegisterComp.js"></script>
|
||||
<script src="/js/components/LoginComp.js"></script>
|
||||
<script src="/js/services/AuthSvc.js"></script>
|
||||
<script src="/js/app.js"></script>
|
||||
</head>
|
||||
|
11
public/views/login-form.html
Normal file
11
public/views/login-form.html
Normal file
@ -0,0 +1,11 @@
|
||||
<form ng-submit="login()">
|
||||
<div class="form-group">
|
||||
<label for="username">Username</label>
|
||||
<input id="username" class="form-control" type="text" ng-model="username"/>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="password">Password</label>
|
||||
<input id="password" class="form-control" type="password" ng-model="password"/>
|
||||
</div>
|
||||
<button type="submit" class="btn">Login</button>
|
||||
</form>
|
24
public/views/login.html
Normal file
24
public/views/login.html
Normal file
@ -0,0 +1,24 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8"/>
|
||||
<base href="/login"/>
|
||||
<title>Login</title>
|
||||
|
||||
<script src="/libs/angular/angular.min.js"></script>
|
||||
<script src="/libs/ng-file-upload/ng-file-upload-all.min.js"></script>
|
||||
<script src="https://cdn.rawgit.com/zenorocha/clipboard.js/master/dist/clipboard.min.js"></script>
|
||||
<script src="/libs/ngclipboard/src/ngclipboard.js"></script>
|
||||
|
||||
<script src="/js/components/UploadComp.js"></script>
|
||||
<script src="/js/components/RegisterComp.js"></script>
|
||||
<script src="/js/components/LoginComp.js"></script>
|
||||
<script src="/js/services/AuthSvc.js"></script>
|
||||
<script src="/js/app.js"></script>
|
||||
</head>
|
||||
<body ng-app="shimapan">
|
||||
<div id="container">
|
||||
<login-component></login-component>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
@ -12,6 +12,7 @@
|
||||
|
||||
<script src="/js/components/UploadComp.js"></script>
|
||||
<script src="/js/components/RegisterComp.js"></script>
|
||||
<script src="/js/components/LoginComp.js"></script>
|
||||
<script src="/js/services/AuthSvc.js"></script>
|
||||
<script src="/js/app.js"></script>
|
||||
</head>
|
||||
|
Loading…
Reference in New Issue
Block a user