Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
U
ulakbus-ui
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ulakbus
ulakbus-ui
Commits
64c06fcf
Commit
64c06fcf
authored
Jul 09, 2015
by
Evren Kutar
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add service file temporary to controller file
save method cmd do
parent
dea59e92
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
84 additions
and
5 deletions
+84
-5
app_routes.js
app/app_routes.js
+3
-3
auth_controller.js
app/components/auth/auth_controller.js
+79
-0
form_service.js
app/zetalib/forms/form_service.js
+2
-2
No files found.
app/app_routes.js
View file @
64c06fcf
...
...
@@ -7,9 +7,9 @@ app.config(['$routeProvider', function ($routeProvider) {
loadMyCtrl
:
[
'$ocLazyLoad'
,
function
(
$ocLazyLoad
)
{
return
$ocLazyLoad
.
load
(
'components/auth/auth_controller.js'
);
}],
loadMyService
:
[
'$ocLazyLoad'
,
function
(
$ocLazyLoad
)
{
return
$ocLazyLoad
.
load
(
'components/auth/auth_service.js'
);
}],
//
loadMyService: ['$ocLazyLoad', function ($ocLazyLoad) {
//
return $ocLazyLoad.load('components/auth/auth_service.js');
//
}],
loadMyService2
:
[
'$ocLazyLoad'
,
function
(
$ocLazyLoad
)
{
return
$ocLazyLoad
.
load
(
'zetalib/forms/form_service.js'
);
}],
...
...
app/components/auth/auth_controller.js
View file @
64c06fcf
...
...
@@ -44,4 +44,83 @@ auth.controller('LoginCtrl', function ($scope, $q, $timeout, $routeParams, Gener
console
.
log
(
"not valid"
);
}
}
});
auth
.
factory
(
'LoginService'
,
function
(
$http
,
$rootScope
,
$location
,
$log
,
$cookies
,
$window
,
Session
,
RESTURL
)
{
var
loginService
=
{};
loginService
.
login
=
function
(
url
,
credentials
)
{
credentials
=
{
login_crd
:
credentials
,
cmd
:
"do"
};
return
$http
.
post
(
RESTURL
.
url
+
url
,
credentials
)
.
success
(
function
(
data
,
status
,
headers
,
config
)
{
//$window.sessionStorage.token = data.token;
$rootScope
.
loggedInUser
=
true
;
})
.
error
(
function
(
data
,
status
,
headers
,
config
)
{
// Erase the token if the user fails to log in
//delete $window.sessionStorage.token;
// Handle login errors here
return
data
;
});
//.then(function (res) {
// $log.info(res.data[0]);
// res.data = res.data[0];
// if (res.data.success) {
// $rootScope.loggedInUser = true;
// $location.path("/dashboard");
// var session = Session.create(res.data.id, res.data.user.id,
// res.data.user.role);
// $log.info(session);
// $cookies.put('sessionId', 123456);
// console.log($cookies.getAll());
// return res.data.user;
// }
//});
};
loginService
.
logout
=
function
()
{
console
.
log
(
"logout"
);
$http
.
post
(
RESTURL
.
url
+
'logout'
,
{}).
then
(
function
(){
$rootScope
.
loggedInUser
=
false
;
$location
.
path
(
"/login"
);
});
console
.
log
(
"loggedout"
);
};
loginService
.
isAuthenticated
=
function
()
{
return
!!
Session
.
userId
;
};
loginService
.
isAuthorized
=
function
(
authorizedRoles
)
{
if
(
!
angular
.
isArray
(
authorizedRoles
))
{
authorizedRoles
=
[
authorizedRoles
];
}
return
(
loginService
.
isAuthenticated
()
&&
loginService
.
indexOf
(
Session
.
userRole
)
!==
-
1
);
};
loginService
.
isValidEmail
=
function
(
email
)
{
var
re
=
/^
([\w
-
]
+
(?:\.[\w
-
]
+
)
*
)
@
((?:[\w
-
]
+
\.)
*
\w[\w
-
]{0,66})\.([
a-z
]{2,6}(?:\.[
a-z
]{2})?)
$/i
;
return
re
.
test
(
email
);
};
return
loginService
;
});
// TODO: initial service not working!!
auth
.
service
(
'Session'
,
function
()
{
this
.
create
=
function
(
sessionId
,
userId
,
userRole
)
{
this
.
id
=
sessionId
;
this
.
userId
=
userId
;
this
.
userRole
=
userRole
;
};
this
.
destroy
=
function
()
{
this
.
id
=
null
;
this
.
userId
=
null
;
this
.
userRole
=
null
;
};
});
\ No newline at end of file
app/zetalib/forms/form_service.js
View file @
64c06fcf
...
...
@@ -46,10 +46,10 @@ form_generator.factory('Generator', function ($http, $q, $log, $timeout, RESTURL
generator
.
submit
=
function
(
$scope
)
{
if
(
$scope
.
object_id
)
{
var
get_diff
=
FormDiff
.
get_diff
(
$scope
.
model
,
$scope
.
initialModel
);
var
data
=
{
"object_id"
:
$scope
.
id
,
"form"
:
get_diff
};
var
data
=
{
"object_id"
:
$scope
.
id
,
"form"
:
get_diff
,
"cmd"
:
"do"
};
}
else
{
data
=
$scope
.
model
;
data
=
{
"form"
:
$scope
.
model
,
"cmd"
:
"do"
}
;
}
$http
.
post
(
generator
.
makeUrl
(
$scope
.
url
),
data
).
then
(
function
(
res
)
{
// todo: for now fake rest api returns 'ok' no data to
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment