Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
irul
/
opensipkd-base
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 0d5e7327
authored
Jun 14, 2022
by
aagusti
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
penyesuaian google client
1 parent
2b1eaed2
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
227 additions
and
196 deletions
opensipkd/base/__init__.py
opensipkd/base/views/base_google.py
opensipkd/base/views/register_external.py
opensipkd/base/views/templates/base3.1.pt
opensipkd/base/views/templates/form_input.pt
opensipkd/base/views/templates/login.pt
opensipkd/base/views/templates/register.pt
opensipkd/base/views/user.py
opensipkd/base/views/user_login.py
opensipkd/base/__init__.py
View file @
0d5e732
...
@@ -116,16 +116,19 @@ def add_global(event):
...
@@ -116,16 +116,19 @@ def add_global(event):
event
[
'get_params'
]
=
get_params
event
[
'get_params'
]
=
get_params
def
get_params
(
params
,
alternate
=
None
):
def
get_params
(
params
,
alternate
=
None
,
settings
=
None
):
"""
"""
Digunakan untuk mengambil nilai dari konfigurasi sesuai params yang disebut
Digunakan untuk mengambil nilai dari konfigurasi sesuai params yang disebut
:param params: variable
:param params: variable
:param alternate: default apabila tidak ditemukan data/params
:param alternate: default apabila tidak ditemukan data/params
:param settings: default settings
:return: value
:return: value
contoh penggunaan:
contoh penggunaan:
get_params('devel', False)
get_params('devel', False)
"""
"""
settings
=
get_settings
()
if
not
settings
:
settings
=
get_settings
()
result
=
settings
and
params
in
settings
and
settings
[
params
]
.
strip
()
or
None
result
=
settings
and
params
in
settings
and
settings
[
params
]
.
strip
()
or
None
if
not
result
:
if
not
result
:
row
=
Parameter
.
query_kode
(
params
)
.
first
()
row
=
Parameter
.
query_kode
(
params
)
.
first
()
...
@@ -425,7 +428,8 @@ def main(global_config, **settings):
...
@@ -425,7 +428,8 @@ def main(global_config, **settings):
config
.
add_static_view
(
'deform_static'
,
'deform:static'
)
config
.
add_static_view
(
'deform_static'
,
'deform:static'
)
# config.add_static_view('files', get_params('static_files'))
# config.add_static_view('files', get_params('static_files'))
# Captcha
# Captcha
captcha_files
=
get_params
(
'captcha_files'
,
'/tmp/captcha'
)
captcha_files
=
get_params
(
'captcha_files'
,
settings
=
settings
,
alternate
=
"/tmp/captcha"
)
if
not
os
.
path
.
exists
(
captcha_files
):
if
not
os
.
path
.
exists
(
captcha_files
):
os
.
makedirs
(
captcha_files
)
os
.
makedirs
(
captcha_files
)
config
.
add_static_view
(
'captcha'
,
captcha_files
)
config
.
add_static_view
(
'captcha'
,
captcha_files
)
...
...
opensipkd/base/views/base_google.py
View file @
0d5e732
from
google.auth.transport
import
requests
from
google.auth.transport
import
requests
from
google.oauth2
import
id_token
from
google.oauth2
import
id_token
from
opensipkd.base
import
get_params
from
pyramid.view
import
(
view_config
,
)
from
pyramid.view
import
(
view_config
,
)
from
..models
import
User
from
..models
import
User
from
opensipkd.tools
import
get_settings
from
opensipkd.tools
import
get_settings
import
json
def
validate_user
(
request
,
idinfo
):
def
validate_user
(
request
,
idinfo
):
...
@@ -51,16 +53,21 @@ def googlesignin(request):
...
@@ -51,16 +53,21 @@ def googlesignin(request):
# (Receive token by HTTPS POST)
# (Receive token by HTTPS POST)
# ...
# ...
CLIENT_IDS
=
request
.
google_signin_client_ids
CLIENT_IDS
=
request
.
google_signin_client_ids
# CLIENT_IDS = get_params('google-signin-client-id')
KEY
=
get_params
(
'google-signin-client-secret'
)
# Specify the CLIENT_ID of the app that accesses the backend:
# Specify the CLIENT_ID of the app that accesses the backend:
# idinfo = id_token.verify_oauth2_token(token, requests.Request(), CLIENT_ID)
# idinfo = id_token.verify_oauth2_token(token, requests.Request(), CLIENT_ID)
# Or, if multiple clients access the backend server:
# Or, if multiple clients access the backend server:
gtoken
=
request
.
params
[
'id_token'
]
gtoken
=
json
.
loads
(
request
.
params
[
'id_token'
])
idinfo
=
id_token
.
verify_oauth2_token
(
gtoken
,
requests
.
Request
())
import
jwt
idinfo
=
jwt
.
decode
(
gtoken
[
"credential"
],
options
=
{
"verify_signature"
:
False
})
# KEY, algorithms=["RS256"]) #
# idinfo = id_token.verify_oauth2_token(gtoken, requests.Request())
if
idinfo
[
'aud'
]
not
in
CLIENT_IDS
:
if
idinfo
[
'aud'
]
not
in
CLIENT_IDS
:
raise
ValueError
(
'Could not verify audience.'
)
raise
ValueError
(
'Could not verify audience.'
)
if
idinfo
[
'iss'
]
not
in
[
'accounts.google.com'
,
'https://accounts.google.com'
]:
if
idinfo
[
'iss'
]
not
in
[
'accounts.google.com'
,
'https://accounts.google.com'
]:
raise
ValueError
(
'Wrong issuer.'
)
raise
ValueError
(
'Wrong issuer.'
)
return
idinfo
return
idinfo
opensipkd/base/views/register_external.py
View file @
0d5e732
...
@@ -180,7 +180,7 @@ def get_form(request, class_form, buttons=None, validator=form_validator):
...
@@ -180,7 +180,7 @@ def get_form(request, class_form, buttons=None, validator=form_validator):
return
Form
(
schema
,
buttons
=
(
'batal'
,
'simpan'
))
return
Form
(
schema
,
buttons
=
(
'batal'
,
'simpan'
))
def
save
(
values
,
user
=
None
,
row
=
None
):
def
save
(
values
,
user
=
None
,
row
=
None
,
request
=
None
):
"""
"""
Digunakan untuk menyimpan User External
Digunakan untuk menyimpan User External
:param values: dictionary of
:param values: dictionary of
...
@@ -198,7 +198,7 @@ def save(values, user=None, row=None):
...
@@ -198,7 +198,7 @@ def save(values, user=None, row=None):
if
not
user
:
if
not
user
:
user_
=
dict
(
user_name
=
values
[
'external_user_name'
],
user_
=
dict
(
user_name
=
values
[
'external_user_name'
],
email
=
values
[
'external_email'
])
email
=
values
[
'external_email'
])
user
,
remail
=
save_user
(
user_
)
user
,
remail
=
save_user
(
request
,
user_
)
if
not
row
:
if
not
row
:
row
=
ExternalIdentity
()
row
=
ExternalIdentity
()
...
@@ -222,9 +222,9 @@ def save_request(values, request, row=None):
...
@@ -222,9 +222,9 @@ def save_request(values, request, row=None):
user
=
ExternalIdentityService
.
user_by_external_id_and_provider
(
user
=
ExternalIdentityService
.
user_by_external_id_and_provider
(
id_info
[
'sub'
],
id_info
[
'iss'
])
id_info
[
'sub'
],
id_info
[
'iss'
])
if
not
user
:
if
not
user
:
user
=
save
(
values
,
user
,
row
)
user
=
save
(
values
,
user
,
row
,
request
)
partner
=
Partner
.
query_
user_id
(
user
.
id
)
.
first
()
partner
=
Partner
.
query_
email
(
id_info
[
'email'
]
)
.
first
()
# if not partner:
# if not partner:
values
[
'email'
]
=
id_info
[
'email'
]
values
[
'email'
]
=
id_info
[
'email'
]
if
'kode'
not
in
values
and
not
values
[
'kode'
]:
if
'kode'
not
in
values
and
not
values
[
'kode'
]:
...
@@ -280,7 +280,7 @@ class RegistrasiExternal(BaseView):
...
@@ -280,7 +280,7 @@ class RegistrasiExternal(BaseView):
values
[
'primari'
][
'email'
]
=
id_info
[
'email'
]
values
[
'primari'
][
'email'
]
=
id_info
[
'email'
]
# values['detail']['captcha']
# values['detail']['captcha']
form
.
set_appstruct
(
values
)
form
.
set_appstruct
(
values
)
return
dict
(
form
=
form
,
captcha
=
get_captcha
(
request
))
return
dict
(
form
=
form
,
captcha
=
get_captcha
(
request
)
,
scripts
=
""
)
dicts
=
dict
(
controls
)
dicts
=
dict
(
controls
)
values
=
dicts
[
'primari'
]
values
=
dicts
[
'primari'
]
...
@@ -317,7 +317,9 @@ class RegistrasiExternal(BaseView):
...
@@ -317,7 +317,9 @@ class RegistrasiExternal(BaseView):
values
[
'secondari'
]
.
update
(
partner
.
to_dict
())
values
[
'secondari'
]
.
update
(
partner
.
to_dict
())
form
.
set_appstruct
(
values
)
form
.
set_appstruct
(
values
)
return
dict
(
form
=
form
,
captcha
=
get_captcha
(
request
))
# return dict()
# return dict(captcha=get_captcha(request))
return
dict
(
form
=
form
.
render
(),
captcha
=
get_captcha
(
request
),
scripts
=
""
)
@view_config
(
route_name
=
'profile-external'
,
renderer
=
'templates/register.pt'
,
@view_config
(
route_name
=
'profile-external'
,
renderer
=
'templates/register.pt'
,
permission
=
'view'
)
permission
=
'view'
)
...
...
opensipkd/base/views/templates/base3.1.pt
View file @
0d5e732
<!DOCTYPE html>
<!DOCTYPE html>
<html
lang=
"en-us"
<html
lang=
"en-us"
tal:define=
"home request.route_url('home')[:-1];
tal:define=
"
user_path ['user', 'user-add', 'user-edit', 'user-view', 'user-delete'
];
home request.route_url('home')[:-1
];
group_path ['group', 'group-add', 'group-edit', 'group-view', 'group
-delete'];
user_path ['user', 'user-add', 'user-edit', 'user-view', 'user
-delete'];
param_path ['parameter', 'parameter-add', 'parameter-edit', 'parameter-view', 'parameter
-delete'];
group_path ['group', 'group-add', 'group-edit', 'group-view', 'group
-delete'];
dep_path ['departemen', 'departemen-add', 'departemen-edit', 'departemen-view', 'departemen
-delete'];
param_path ['parameter', 'parameter-add', 'parameter-edit', 'parameter-view', 'parameter
-delete'];
partner_path ['partner', 'partner-add', 'partner-edt', 'partner-view', 'partner-del
'];
dep_path ['departemen', 'departemen-add', 'departemen-edit', 'departemen-view', 'departemen-delete
'];
company_path ['company', 'company-add', 'company-edt', 'company-view', 'company
-del'];
partner_path ['partner', 'partner-add', 'partner-edt', 'partner-view', 'partner
-del'];
part_dep_path ['partner-departemen', 'partner-departemen-add', 'partner-departemen-edit', 'partner-departemen-view',
company_path ['company', 'company-add', 'company-edt', 'company-view', 'company-del'];
'partner-departemen-delete'];
part_dep_path ['partner-departemen', 'partner-departemen-add', 'partner-departemen-edit', 'partner-departemen-view',
'partner-departemen-delete'];
jabatan_path ['jabatan', 'jabatan-add', 'jabatan-edit', 'jabatan-view', 'jabatan-delete'];
jabatan_path ['jabatan', 'jabatan-add', 'jabatan-edit', 'jabatan-view', 'jabatan-delete'];
eselon_path ['eselon', 'eselon-add', 'eselon-edit', 'eselon-view', 'eselon-delete'];
eselon_path ['eselon', 'eselon-add', 'eselon-edit', 'eselon-view', 'eselon-delete'];
provinsi_path ['provinsi', 'provinsi-add', 'provinsi-edit', 'provinsi-view', 'provinsi-delete'];
provinsi_path ['provinsi', 'provinsi-add', 'provinsi-edit', 'provinsi-view', 'provinsi-delete'];
dati2_path ['dati2', 'dati2-add', 'dati2-edit', 'dati2-view', 'dati2-delete'];
dati2_path ['dati2', 'dati2-add', 'dati2-edit', 'dati2-view', 'dati2-delete'];
kecamatan_path ['kecamatan', 'kecamatan-add', 'kecamatan-edit', 'kecamatan-view', 'kecamatan-delete'];
kecamatan_path ['kecamatan', 'kecamatan-add', 'kecamatan-edit', 'kecamatan-view', 'kecamatan-delete'];
desa_path ['desa', 'desa-add', 'desa-edit', 'desa-view', 'desa-delete'];
desa_path ['desa', 'desa-add', 'desa-edit', 'desa-view', 'desa-delete'];
"
>
"
>
<head>
<head>
<!--<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">-->
<!--<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">-->
...
@@ -179,67 +179,67 @@
...
@@ -179,67 +179,67 @@
<!-- Admin Menu -->
<!-- Admin Menu -->
<ul
<ul
tal:condition=
"has_permission(request, user_path)"
tal:condition=
"has_permission(request, user_path)"
style=
"margin-top: 0; padding-top: 0;"
>
style=
"margin-top: 0; padding-top: 0;"
>
<li>
<li>
<a
href=
"#"
><i
class=
"fa fa-lg fa-fw fa-shield"
></i>
<a
href=
"#"
><i
class=
"fa fa-lg fa-fw fa-shield"
></i>
<span
class=
"menu-item-parent"
>
Admin
</span></a>
<span
class=
"menu-item-parent"
>
Admin
</span></a>
<ul>
<ul>
<li
tal:condition=
"has_permission(request, ['user-view', 'user-edit'])"
<li
tal:condition=
"has_permission(request, ['user-view', 'user-edit'])"
tal:attributes=
"class request.matched_route.name in user_path and 'active'"
>
tal:attributes=
"class request.matched_route.name in user_path and 'active'"
>
<a
href=
"${home}/user"
>
User
</a>
<a
href=
"${home}/user"
>
User
</a>
</li>
</li>
<li
tal:condition=
"has_permission(request, ['user-view', 'user-edit'])"
<li
tal:condition=
"has_permission(request, ['user-view', 'user-edit'])"
tal:attributes=
"class request.matched_route.name in group_path and 'active'"
>
tal:attributes=
"class request.matched_route.name in group_path and 'active'"
>
<a
href=
"${home}/group"
>
Group
</a>
<a
href=
"${home}/group"
>
Group
</a>
</li>
</li>
<!-- <li tal:condition="has_permission(request, 'user-group')"-->
<!-- <li tal:condition="has_permission(request, 'user-group')"-->
<!-- tal:attributes="class request.matched_route.name in ['user-group'] and 'active'">-->
<!-- tal:attributes="class request.matched_route.name in ['user-group'] and 'active'">-->
<!-- <a href="${home}/user/group">User Group</a></li>-->
<!-- <a href="${home}/user/group">User Group</a></li>-->
<li
tal:condition=
"has_permission(request, 'upload-logo')"
<li
tal:condition=
"has_permission(request, 'upload-logo')"
tal:attributes=
"class request.matched_route.name in ['upload-logo'] and 'active'"
>
tal:attributes=
"class request.matched_route.name in ['upload-logo'] and 'active'"
>
<a
href=
"${home}/upload/logo"
>
Upload Logo
</a></li>
<a
href=
"${home}/upload/logo"
>
Upload Logo
</a></li>
<li
tal:condition=
"has_permission(request, 'parameter')"
<li
tal:condition=
"has_permission(request, 'parameter')"
tal:attributes=
"class request.matched_route.name in param_path and 'active'"
>
tal:attributes=
"class request.matched_route.name in param_path and 'active'"
>
<a
href=
"${home}/parameter"
>
Parameter
</a></li>
<a
href=
"${home}/parameter"
>
Parameter
</a></li>
<li
tal:condition=
"has_permission(request, 'company')"
<li
tal:condition=
"has_permission(request, 'company')"
tal:attributes=
"class request.matched_route.name in company_path and 'active'"
>
tal:attributes=
"class request.matched_route.name in company_path and 'active'"
>
<a
href=
"${home}/company"
>
Pemerintah
</a></li>
<a
href=
"${home}/company"
>
Pemerintah
</a></li>
<li
tal:condition=
"has_permission(request, 'eselon')"
<li
tal:condition=
"has_permission(request, 'eselon')"
tal:attributes=
"class request.matched_route.name in eselon_path and 'active'"
>
tal:attributes=
"class request.matched_route.name in eselon_path and 'active'"
>
<a
href=
"${home}/eselon"
>
Eselon
</a></li>
<a
href=
"${home}/eselon"
>
Eselon
</a></li>
<li
tal:condition=
"has_permission(request, 'jabatan')"
<li
tal:condition=
"has_permission(request, 'jabatan')"
tal:attributes=
"class request.matched_route.name in jabatan_path and 'active'"
>
tal:attributes=
"class request.matched_route.name in jabatan_path and 'active'"
>
<a
href=
"${home}/jabatan"
>
Jabatan
</a></li>
<a
href=
"${home}/jabatan"
>
Jabatan
</a></li>
<li
tal:condition=
"has_permission(request, 'departemen')"
<li
tal:condition=
"has_permission(request, 'departemen')"
tal:attributes=
"class request.matched_route.name in dep_path and 'active'"
>
tal:attributes=
"class request.matched_route.name in dep_path and 'active'"
>
<a
href=
"${home}/departemen"
>
Departemen
</a></li>
<a
href=
"${home}/departemen"
>
Departemen
</a></li>
<!-- <li tal:condition="has_permission(request, 'departemen-user')"-->
<!-- <li tal:condition="has_permission(request, 'departemen-user')"-->
<!-- tal:attributes="class request.matched_route.name in ['departemen-user'] and 'active'">-->
<!-- tal:attributes="class request.matched_route.name in ['departemen-user'] and 'active'">-->
<!-- <a href="${home}/departemen/user">User Departemen</a></li>-->
<!-- <a href="${home}/departemen/user">User Departemen</a></li>-->
<li
tal:condition=
"has_permission(request, 'partner')"
<li
tal:condition=
"has_permission(request, 'partner')"
tal:attributes=
"class request.matched_route.name in partner_path and 'active'"
>
tal:attributes=
"class request.matched_route.name in partner_path and 'active'"
>
<a
href=
"${home}/partner"
>
Partner
</a></li>
<a
href=
"${home}/partner"
>
Partner
</a></li>
<li
tal:condition=
"has_permission(request, 'partner-departemen')"
<li
tal:condition=
"has_permission(request, 'partner-departemen')"
tal:attributes=
"class request.matched_route.name in part_dep_path and 'active'"
>
tal:attributes=
"class request.matched_route.name in part_dep_path and 'active'"
>
<a
href=
"${home}/partner/departemen"
>
Partner Departemen
</a></li>
<a
href=
"${home}/partner/departemen"
>
Partner Departemen
</a></li>
<li
tal:condition=
"has_permission(request, 'provinsi')"
<li
tal:condition=
"has_permission(request, 'provinsi')"
tal:attributes=
"class request.matched_route.name in provinsi_path and 'active'"
>
tal:attributes=
"class request.matched_route.name in provinsi_path and 'active'"
>
<a
href=
"${home}/provinsi"
>
Provinsi
</a></li>
<a
href=
"${home}/provinsi"
>
Provinsi
</a></li>
<li
tal:condition=
"has_permission(request, 'dati2')"
<li
tal:condition=
"has_permission(request, 'dati2')"
tal:attributes=
"class request.matched_route.name in dati2_path and 'active'"
>
tal:attributes=
"class request.matched_route.name in dati2_path and 'active'"
>
<a
href=
"${home}/dati2"
>
Kabupaten/Kota
</a></li>
<a
href=
"${home}/dati2"
>
Kabupaten/Kota
</a></li>
<li
tal:condition=
"has_permission(request, 'kecamatan')"
<li
tal:condition=
"has_permission(request, 'kecamatan')"
tal:attributes=
"class request.matched_route.name in kecamatan_path and 'active'"
>
tal:attributes=
"class request.matched_route.name in kecamatan_path and 'active'"
>
<a
href=
"${home}/kecamatan"
>
Kecamatan
</a></li>
<a
href=
"${home}/kecamatan"
>
Kecamatan
</a></li>
<li
tal:condition=
"has_permission(request, 'desa')"
<li
tal:condition=
"has_permission(request, 'desa')"
tal:attributes=
"class request.matched_route.name in desa_path and 'active'"
>
tal:attributes=
"class request.matched_route.name in desa_path and 'active'"
>
<a
href=
"${home}/desa"
>
Desa/Kelurahan
</a></li>
<a
href=
"${home}/desa"
>
Desa/Kelurahan
</a></li>
<li
tal:condition=
"has_permission(request, 'log')"
<li
tal:condition=
"has_permission(request, 'log')"
tal:attributes=
"class request.matched_route.name in ['log'] and 'active'"
>
tal:attributes=
"class request.matched_route.name in ['log'] and 'active'"
>
<a
href=
"${home}/log"
>
Log
</a></li>
<a
href=
"${home}/log"
>
Log
</a></li>
</ul>
</ul>
</li>
</li>
...
@@ -349,14 +349,14 @@
...
@@ -349,14 +349,14 @@
// Strip all characters but numerical ones.
// Strip all characters but numerical ones.
number
=
(
number
+
''
).
replace
(
/
[^
0-9+
\-
Ee.
]
/g
,
''
);
number
=
(
number
+
''
).
replace
(
/
[^
0-9+
\-
Ee.
]
/g
,
''
);
var
n
=
!
isFinite
(
+
number
)
?
0
:
+
number
,
var
n
=
!
isFinite
(
+
number
)
?
0
:
+
number
,
prec
=
!
isFinite
(
+
decimals
)
?
0
:
Math
.
abs
(
decimals
),
prec
=
!
isFinite
(
+
decimals
)
?
0
:
Math
.
abs
(
decimals
),
sep
=
(
typeof
thousands_sep
===
'undefined'
)
?
','
:
thousands_sep
,
sep
=
(
typeof
thousands_sep
===
'undefined'
)
?
','
:
thousands_sep
,
dec
=
(
typeof
dec_point
===
'undefined'
)
?
'.'
:
dec_point
,
dec
=
(
typeof
dec_point
===
'undefined'
)
?
'.'
:
dec_point
,
s
=
''
,
s
=
''
,
toFixedFix
=
function
(
n
,
prec
)
{
toFixedFix
=
function
(
n
,
prec
)
{
var
k
=
Math
.
pow
(
10
,
prec
);
var
k
=
Math
.
pow
(
10
,
prec
);
return
''
+
Math
.
round
(
n
*
k
)
/
k
;
return
''
+
Math
.
round
(
n
*
k
)
/
k
;
};
};
// Fix for IE parseFloat(0.55).toFixed(0) = 0;
// Fix for IE parseFloat(0.55).toFixed(0) = 0;
s
=
(
prec
?
toFixedFix
(
n
,
prec
)
:
''
+
Math
.
round
(
n
)).
split
(
'.'
);
s
=
(
prec
?
toFixedFix
(
n
,
prec
)
:
''
+
Math
.
round
(
n
)).
split
(
'.'
);
if
(
s
[
0
].
length
>
3
)
{
if
(
s
[
0
].
length
>
3
)
{
...
...
opensipkd/base/views/templates/form_input.pt
View file @
0d5e732
...
@@ -22,9 +22,8 @@
...
@@ -22,9 +22,8 @@
$
{
structure
:
scripts
}
$
{
structure
:
scripts
}
});
});
</script>
</script>
<div
metal:define-slot=
"scripts"
>
<div
metal:define-slot=
"scripts"
></div>
</div>
</div>
</div>
</html>
</html>
opensipkd/base/views/templates/login.pt
View file @
0d5e732
<!DOCTYPE html>
<!DOCTYPE html>
<html
lang=
"en"
<html
lang=
"en"
tal:define=
"home request.route_url('home')[:-1];"
>
tal:define=
"home request.route_url('home')[:-1];"
>
<head>
<head>
<meta
charset=
"utf-8"
>
<meta
charset=
"utf-8"
>
<meta
http-equiv=
"X-UA-Compatible"
content=
"IE=edge"
>
<meta
http-equiv=
"X-UA-Compatible"
content=
"IE=edge"
>
<meta
name=
"description"
content=
""
>
<meta
name=
"description"
content=
""
>
<meta
name=
"author"
content=
""
>
<meta
name=
"author"
content=
""
>
<meta
name=
"viewport"
content=
"width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"
>
<meta
name=
"viewport"
content=
"width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"
>
<meta
tal:condition=
"request.google_signin_client_id"
<!--? <meta tal:condition="request.google_signin_client_id"-->
name=
"google-signin-client_id"
<!--? name="google-signin-client_id"-->
content=
"${request.google_signin_client_id}"
>
<!--? content="${request.google_signin_client_id}">--
>
<link
rel=
"shortcut icon"
href=
"${home}/static/img/favicon.png"
>
<link
rel=
"shortcut icon"
href=
"${home}/static/img/favicon.png"
>
<title
tal:content=
"request.title"
/>
<title
tal:content=
"request.title"
/>
<!-- Basic Styles -->
<!-- Basic Styles -->
<link
rel=
"stylesheet"
type=
"text/css"
media=
"screen"
href=
"${home}/static/v3/css/bootstrap.min.css"
>
<link
rel=
"stylesheet"
type=
"text/css"
media=
"screen"
href=
"${home}/static/v3/css/bootstrap.min.css"
>
<link
rel=
"stylesheet"
type=
"text/css"
media=
"screen"
href=
"${home}/static/v3/css/font-awesome.min.css"
>
<link
rel=
"stylesheet"
type=
"text/css"
media=
"screen"
href=
"${home}/static/v3/css/font-awesome.min.css"
>
<!-- SmartAdmin Styles : Caution! DO NOT change the order -->
<!-- SmartAdmin Styles : Caution! DO NOT change the order -->
<link
rel=
"stylesheet"
type=
"text/css"
media=
"screen"
href=
"${home}/static/v3/css/smartadmin-production-plugins.min.css"
>
<link
rel=
"stylesheet"
type=
"text/css"
media=
"screen"
href=
"${home}/static/v3/css/smartadmin-production-plugins.min.css"
>
<link
rel=
"stylesheet"
type=
"text/css"
media=
"screen"
href=
"${home}/static/v3/css/smartadmin-production.min.css"
>
<link
rel=
"stylesheet"
type=
"text/css"
media=
"screen"
href=
"${home}/static/v3/css/smartadmin-production.min.css"
>
<link
rel=
"stylesheet"
type=
"text/css"
media=
"screen"
href=
"${home}/static/v3/css/smartadmin-skins.min.css"
>
<link
rel=
"stylesheet"
type=
"text/css"
media=
"screen"
href=
"${home}/static/v3/css/smartadmin-skins.min.css"
>
...
@@ -27,133 +28,149 @@
...
@@ -27,133 +28,149 @@
<link
rel=
"stylesheet"
type=
"text/css"
media=
"screen"
href=
"${home}/static/v3/css/smartadmin-rtl.min.css"
>
<link
rel=
"stylesheet"
type=
"text/css"
media=
"screen"
href=
"${home}/static/v3/css/smartadmin-rtl.min.css"
>
<link
rel=
"stylesheet"
type=
"text/css"
href=
"${home}/static/css/custom.css"
>
<link
rel=
"stylesheet"
type=
"text/css"
href=
"${home}/static/css/custom.css"
>
</head>
</head>
<body>
<body>
<div
id=
"content"
class=
"container"
>
<div
id=
"content"
class=
"container"
>
<div
class=
"row"
>
<div
class=
"row"
>
<div
class=
"col-xs-12 col-sm-12 col-md-6 col-md-offset-3 col-lg-4 col-lg-offset-4"
style=
"margin-top:50px"
>
<div
class=
"col-xs-12 col-sm-12 col-md-6 col-md-offset-3 col-lg-4 col-lg-offset-4"
style=
"margin-top:50px"
>
<div
class=
"well no-padding"
>
<div
class=
"well no-padding"
>
<form
id=
"deform"
method=
"POST"
enctype=
"multipart/form-data"
accept-charset=
"utf-8"
<form
id=
"deform"
method=
"POST"
enctype=
"multipart/form-data"
accept-charset=
"utf-8"
class=
"smart-form client-form panel form-signin"
style=
"border:0px;"
>
class=
"smart-form client-form panel form-signin"
style=
"border:0px;"
>
<header
class=
"bg-color-blue"
>
<header
class=
"bg-color-blue"
>
<h1
class=
"txt-color-white login-header-big"
align=
"center"
style=
"letter-spacing:1px;"
>
${request.app_name}
</h1>
<h1
class=
"txt-color-white login-header-big"
align=
"center"
</header>
style=
"letter-spacing:1px;"
>
${request.app_name}
</h1>
</header>
<fieldset
class=
"deformFormFieldset"
>
<input
type=
"hidden"
name=
"_charset_"
/>
<fieldset
class=
"deformFormFieldset"
>
<input
type=
"hidden"
name=
"__formid__"
value=
"deform"
/>
<input
type=
"hidden"
name=
"_charset_"
/>
<div
tal:condition=
"request.session.peek_flash()"
>
<input
type=
"hidden"
name=
"__formid__"
value=
"deform"
/>
<div
class=
"alert alert-success"
tal:repeat=
"message request.session.pop_flash()"
><i
<div
tal:condition=
"request.session.peek_flash()"
>
class=
"fa fa-fw fa-lg fa-check-circle"
></i>
${message}
<div
class=
"alert alert-success"
tal:repeat=
"message request.session.pop_flash()"
><i
</div>
class=
"fa fa-fw fa-lg fa-check-circle"
></i>
${message}
</div>
</div>
<div
tal:condition=
"request.session.peek_flash('error')"
>
</div>
<div
class=
"alert alert-danger"
tal:repeat=
"message request.session.pop_flash('error')"
><i
<div
tal:condition=
"request.session.peek_flash('error')"
>
class=
"fa fa-fw fa-lg fa-times-circle"
></i>
${message}
<div
class=
"alert alert-danger"
tal:repeat=
"message request.session.pop_flash('error')"
><i
</div>
class=
"fa fa-fw fa-lg fa-times-circle"
></i>
${message}
</div>
</div>
</div>
<div
class=
"col-md-12"
align=
"center"
>
<img
src=
"${home}/static/img/logo.png"
<div
class=
"col-md-12"
align=
"center"
>
class=
"img-float img-thumbnail"
style=
"height:auto;width:auto;border:none;"
/>
<img
src=
"${home}/static/img/logo.png"
</div>
class=
"img-float img-thumbnail"
style=
"height:auto;width:auto;border:none;"
/>
</div>
<div
class=
"clearfix"
></div>
<div
class=
"clearfix"
></div>
<section>
<label
class=
"label"
>
USERNAME
</label>
<section>
<label
class=
"input"
>
<i
class=
"icon-append fa fa-user"
></i>
<label
class=
"label"
>
USERNAME
</label>
<input
id=
"username"
type=
"text"
name=
"username"
class=
"form-control"
>
<label
class=
"input"
>
<i
class=
"icon-append fa fa-user"
></i>
<b
class=
"tooltip tooltip-top-right"
>
<input
id=
"username"
type=
"text"
name=
"username"
class=
"form-control"
>
<i
class=
"fa fa-user txt-color-teal"
></i>
<b
class=
"tooltip tooltip-top-right"
>
ISI DENGAN USERNAME ANDA
</b></label>
<i
class=
"fa fa-user txt-color-teal"
></i>
</section>
ISI DENGAN USERNAME ANDA
</b></label>
</section>
<section>
<label
class=
"label"
>
PASSWORD
</label>
<section>
<label
class=
"input"
>
<i
class=
"icon-append fa fa-lock"
></i>
<label
class=
"label"
>
PASSWORD
</label>
<input
id=
"password"
type=
"password"
name=
"password"
class=
"form-control"
>
<label
class=
"input"
>
<i
class=
"icon-append fa fa-lock"
></i>
<b
class=
"tooltip tooltip-top-right"
><i
class=
"fa fa-lock txt-color-teal"
></i>
ISI DENGAN PASSWORD ANDA
</b>
</label>
<input
id=
"password"
type=
"password"
name=
"password"
class=
"form-control"
>
<div
class=
"note"
>
<b
class=
"tooltip tooltip-top-right"
><i
class=
"fa fa-lock txt-color-teal"
></i>
ISI
<a
id=
"lupa"
name=
"lupa"
DENGAN PASSWORD ANDA
</b>
</label>
href=
"${home}/reset-password"
>
Lupa Password?
</a>
<div
class=
"note"
>
</div>
<a
id=
"lupa"
name=
"lupa"
</section>
href=
"${home}/reset-password"
>
Lupa Password?
</a>
<section>
</div>
<input
id=
"provider_name"
type=
"hidden"
name=
"provider_name"
class=
"form-control"
>
</section>
<input
id=
"id_token"
type=
"hidden"
name=
"id_token"
class=
"form-control"
>
<section>
</section>
<input
id=
"provider_name"
type=
"hidden"
name=
"provider_name"
class=
"form-control"
>
<input
id=
"id_token"
type=
"hidden"
name=
"id_token"
class=
"form-control"
>
</fieldset>
</section>
<footer>
<div
style=
"float:right"
>
</fieldset>
<button
type=
"submit"
id=
"login-btn"
name=
"login"
<footer>
<div
style=
"float:right"
>
<button
type=
"submit"
id=
"login-btn"
name=
"login"
class=
"btn btn-primary"
style=
"float:left"
class=
"btn btn-primary"
style=
"float:left"
value=
"Login"
>
value=
"Login"
>
Login
Login
</button>
</button>
<button
tal:condition=
"allow_register(request)"
<button
tal:condition=
"allow_register(request)"
id=
"register"
name=
"register"
class=
"btn btn-info"
id=
"register"
name=
"register"
class=
"btn btn-info"
value=
"Register"
style=
"float:left"
>
value=
"Register"
style=
"float:left"
>
Register
Register
</button>
</button>
<div
class=
"clearfix"
></div>
<div
class=
"clearfix"
></div>
</div>
</div>
<div
<!--? <div-->
style=
"margin-top:10px;"
tal:condition=
"request.google_signin_client_id and allow_register(request)"
<!--? style="margin-top:10px;" tal:condition="request.google_signin_client_id and allow_register(request)"-->
class=
"g-signin2 text-center"
<!--? class="g-signin2 text-center"-->
data-onsuccess=
"onSignIn"
>
<!--? data-onsuccess="onSignIn">handleCredentialResponse-->
</div>
<!--? </div>-->
<div
tal:condition=
"request.google_signin_client_id and allow_register(request)"
>
</footer>
<div
id=
"g_id_onload"
data-client_id=
"${request.google_signin_client_id}"
data-callback=
"onSignIn"
>
</form>
</div>
</div>
<div
class=
"g_id_signin"
data-type=
"standard"
></div>
</div>
</div>
</footer>
</form>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- Bootstrap core JavaScript
<!-- Bootstrap core JavaScript
================================================== -->
================================================== -->
<!-- Placed at the end of the document so the pages load faster -->
<!-- Placed at the end of the document so the pages load faster -->
<script
type=
"text/javascript"
src=
"${home}/deform_static/scripts/jquery-2.0.3.min.js"
></script>
<script
type=
"text/javascript"
src=
"${home}/deform_static/scripts/jquery-2.0.3.min.js"
></script>
<script
type=
"text/javascript"
src=
"${home}/deform_static/scripts/bootstrap.min.js"
></script>
<script
type=
"text/javascript"
src=
"${home}/deform_static/scripts/bootstrap.min.js"
></script>
<script
type=
"text/javascript"
src=
"${home}/deform_static/scripts/deform.js"
></script>
<script
type=
"text/javascript"
src=
"${home}/deform_static/scripts/deform.js"
></script>
<script
tal:condition=
"request.google_signin_client_id"
<!--? <script tal:condition="request.google_signin_client_id"-->
src=
"https://apis.google.com/js/platform.js"
async
defer
></script>
<!--? src="https://apis.google.com/js/platform.js" async defer></script>-->
<script
tal:condition=
"request.google_signin_client_id"
>
<script
tal:condition=
"request.google_signin_client_id"
function
onSignIn
(
googleUser
)
{
src=
"https://accounts.google.com/gsi/client"
async
defer
></script>
var
profile
=
googleUser
.
getBasicProfile
();
// console.log('ID: ' + profile.getId()); // Do not send to your backend! Use an ID token instead.
// console.log('Name: ' + profile.getName());
// console.log('Image URL: ' + profile.getImageUrl());
// console.log('Email: ' + profile.getEmail()); // This is null if the 'email' scope is not present.
var
id_token
=
googleUser
.
getAuthResponse
().
id_token
;
document
.
getElementById
(
'provider_name'
).
value
=
"google"
;
document
.
getElementById
(
'id_token'
).
value
=
id_token
;
document
.
getElementById
(
"deform"
).
submit
();
// var xhr = new XMLHttpRequest();
// xhr.open('POST', '/googlesignin');
// xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
// xhr.onload = function() {
// console.log('Signed in as: ' + xhr.responseText);
// };
// xhr.send('idtoken=' + id_token);
}
$
(
document
).
ready
(
function
()
{
<script
tal:condition=
"request.google_signin_client_id"
>
$
(
"form#deform"
).
keypress
(
function
(
event
)
{
function
onSignIn
(
googleUser
)
{
var
keycode
=
(
event
.
keyCode
?
event
.
keyCode
:
event
.
which
);
// var profile = googleUser.getBasicProfile();
if
(
keycode
==
'13'
){
// console.log('ID: ' + profile.getId()); // Do not send to your backend! Use an ID token instead.
event
.
preventDefault
();
// console.log('Name: ' + profile.getName());
$
(
"button#login-btn"
).
click
();
// console.log('Image URL: ' + profile.getImageUrl());
}
// console.log('Email: ' + profile.getEmail()); // This is null if the 'email' scope is not present.
});
//getId(), getName(), getGivenName(), getFamilyName(), getImageUrl(), getEmail() methods, and
});
console
.
log
(
googleUser
);
</script>
// console.log(googleUser.getId());
</body>
// console.log(googleUser.getName());
// var id_token = googleUser.getAuthResponse().id_token;
document
.
getElementById
(
'provider_name'
).
value
=
"google"
;
document
.
getElementById
(
'id_token'
).
value
=
JSON
.
stringify
(
googleUser
);
document
.
getElementById
(
"deform"
).
submit
();
// var xhr = new XMLHttpRequest();
// xhr.open('POST', '/googlesignin');
// xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
// xhr.onload = function() {
// console.log('Signed in as: ' + xhr.responseText);
// };
// xhr.send('idtoken=' + id_token);
}
$
(
document
).
ready
(
function
()
{
$
(
"form#deform"
).
keypress
(
function
(
event
)
{
var
keycode
=
(
event
.
keyCode
?
event
.
keyCode
:
event
.
which
);
if
(
keycode
==
'13'
)
{
event
.
preventDefault
();
$
(
"button#login-btn"
).
click
();
}
});
});
</script>
</body>
</html>
</html>
opensipkd/base/views/templates/register.pt
View file @
0d5e732
<html
metal:use-macro=
"load: form_input.pt"
>
<html
metal:use-macro=
"load: form_input.pt"
tal:define=
"home request.route_url('home')[:-1];"
>
<div
metal:fill-slot=
"scripts"
>
<div
metal:fill-slot=
"scripts"
>
<script>
<script>
$
(
document
).
ready
(
function
()
{
$
(
document
).
ready
(
function
()
{
...
@@ -11,7 +13,6 @@
...
@@ -11,7 +13,6 @@
});
});
});
});
});
});
</script>
</script>
</div>
</div>
...
...
opensipkd/base/views/user.py
View file @
0d5e732
...
@@ -6,6 +6,7 @@ import transaction
...
@@ -6,6 +6,7 @@ import transaction
from
datatables
import
(
ColumnDT
,
DataTables
,
)
from
datatables
import
(
ColumnDT
,
DataTables
,
)
from
deform
import
(
Form
,
widget
,
ValidationFailure
,
Button
,
)
from
deform
import
(
Form
,
widget
,
ValidationFailure
,
Button
,
)
# from sqlalchemy.exc import IntegrityErrortpl
# from sqlalchemy.exc import IntegrityErrortpl
from
sqlalchemy.exc
import
IntegrityError
from
opensipkd.tools
import
create_now
from
opensipkd.tools
import
create_now
from
opensipkd.tools.buttons
import
btn_cancel
,
btn_save
,
btn_close
from
opensipkd.tools.buttons
import
btn_cancel
,
btn_save
,
btn_close
...
...
opensipkd/base/views/user_login.py
View file @
0d5e732
...
@@ -122,23 +122,23 @@ def view_login(request):
...
@@ -122,23 +122,23 @@ def view_login(request):
return
r
return
r
elif
"provider_name"
in
request
.
params
and
request
.
params
[
"provider_name"
]:
elif
"provider_name"
in
request
.
params
and
request
.
params
[
"provider_name"
]:
# checking jika mengggunakan openid seperti google atau facebook
provider_name
=
request
.
params
[
"provider_name"
]
provider_name
=
request
.
params
[
"provider_name"
]
if
provider_name
==
"google"
:
if
provider_name
==
"google"
:
from
.base_google
import
googlesignin
from
.base_google
import
googlesignin
# user = googlesignin(request)
# user = googlesignin(request)
id_info
=
googlesignin
(
request
)
request
.
session
[
"id_info"
]
=
id_info
try
:
try
:
id_info
=
googlesignin
(
request
)
pass
request
.
session
[
"id_info"
]
=
id_info
except
ValueError
as
e
:
except
ValueError
as
e
:
request
.
session
.
flash
(
e
,
'error'
)
request
.
session
.
flash
(
e
,
'error'
)
raise
HTTPNotFound
raise
HTTPNotFound
else
:
else
:
id_info
=
None
id_info
=
None
user
=
id_info
and
ExternalIdentityService
.
\
user
=
id_info
and
ExternalIdentityService
.
\
user_by_external_id_and_provider
(
id_info
[
'sub'
],
id_info
[
'iss'
])
user_by_external_id_and_provider
(
id_info
[
'sub'
],
id_info
[
'iss'
])
if
id_info
and
not
user
:
if
id_info
and
not
user
:
request
.
session
.
flash
(
'Silahkan Melakukan Registrasi'
)
request
.
session
.
flash
(
'Silahkan Melakukan Registrasi'
)
return
HTTPFound
(
location
=
request
.
route_url
(
'register-external'
))
return
HTTPFound
(
location
=
request
.
route_url
(
'register-external'
))
...
...
Write
Preview
Markdown
is supported
Attach a file
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 post a comment