Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
ProtalMahasiswa
Project
Overview
Details
Activity
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
Reynaldo Leoricci Mikhael
ProtalMahasiswa
Commits
f8bc488f
Commit
f8bc488f
authored
Nov 24, 2017
by
Reynaldo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
First commit
parent
0bb2180e
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
207 additions
and
78 deletions
+207
-78
AppAsset.php
backend/assets/AppAsset.php
+1
-0
SiteController.php
backend/controllers/SiteController.php
+23
-6
main-login.php
backend/views/layouts/main-login.php
+41
-0
main.php
backend/views/layouts/main.php
+74
-62
login.php
backend/views/site/login.php
+29
-10
background.css
backend/web/css/background.css
+28
-0
logo_new_v02.png
backend/web/img/logo_new_v02.png
+0
-0
LoginForm.php
common/models/LoginForm.php
+4
-0
site.css
frontend/web/css/site.css
+7
-0
No files found.
backend/assets/AppAsset.php
View file @
f8bc488f
...
@@ -13,6 +13,7 @@ class AppAsset extends AssetBundle
...
@@ -13,6 +13,7 @@ class AppAsset extends AssetBundle
public
$baseUrl
=
'@web'
;
public
$baseUrl
=
'@web'
;
public
$css
=
[
public
$css
=
[
'css/site.css'
,
'css/site.css'
,
'css/background.css'
,
];
];
public
$js
=
[
public
$js
=
[
];
];
...
...
backend/controllers/SiteController.php
View file @
f8bc488f
...
@@ -6,6 +6,7 @@ use yii\web\Controller;
...
@@ -6,6 +6,7 @@ use yii\web\Controller;
use
yii\filters\VerbFilter
;
use
yii\filters\VerbFilter
;
use
yii\filters\AccessControl
;
use
yii\filters\AccessControl
;
use
common\models\LoginForm
;
use
common\models\LoginForm
;
use
yii\web\Response
;
/**
/**
* Site controller
* Site controller
...
@@ -22,11 +23,11 @@ class SiteController extends Controller
...
@@ -22,11 +23,11 @@ class SiteController extends Controller
'class'
=>
AccessControl
::
className
(),
'class'
=>
AccessControl
::
className
(),
'rules'
=>
[
'rules'
=>
[
[
[
'actions'
=>
[
'login'
,
'error'
],
'actions'
=>
[
'login'
,
'error'
,
'index'
],
'allow'
=>
true
,
'allow'
=>
true
,
],
],
[
[
'actions'
=>
[
'logout'
,
'index'
],
'actions'
=>
[
'logout'
],
'allow'
=>
true
,
'allow'
=>
true
,
'roles'
=>
[
'@'
],
'roles'
=>
[
'@'
],
],
],
...
@@ -70,13 +71,29 @@ class SiteController extends Controller
...
@@ -70,13 +71,29 @@ class SiteController extends Controller
*/
*/
public
function
actionLogin
()
public
function
actionLogin
()
{
{
if
(
!
Yii
::
$app
->
user
->
isGuest
)
{
$model
=
new
LoginForm
();
if
(
!
Yii
::
$app
->
user
->
isGuest
){
return
$this
->
goHome
();
return
$this
->
goHome
();
}
}
$model
=
new
LoginForm
();
if
(
$model
->
load
(
Yii
::
$app
->
request
->
post
())){
if
(
$model
->
load
(
Yii
::
$app
->
request
->
post
())
&&
$model
->
login
())
{
$url
=
'https://cis.del.ac.id/api/authentication/do-auth'
;
return
$this
->
goBack
();
$data
=
array
(
'username'
=>
$model
->
username
,
'password'
=>
$model
->
password
);
$options
=
array
(
'http'
=>
array
(
'header'
=>
"Content-type: application/x-www-form-urlencoded
\r\n
"
,
'method'
=>
'POST'
,
'content'
=>
http_build_query
(
$data
),
)
);
$context
=
stream_context_create
(
$options
);
$result
=
file_get_contents
(
$url
,
false
,
$context
);
\Yii
::
$app
->
response
->
format
=
Response
::
FORMAT_JSON
;
echo
parent
::
$result
;
die
();
return
$this
->
redirect
([
'/site/index'
]);
}
else
{
}
else
{
return
$this
->
render
(
'login'
,
[
return
$this
->
render
(
'login'
,
[
'model'
=>
$model
,
'model'
=>
$model
,
...
...
backend/views/layouts/main-login.php
0 → 100644
View file @
f8bc488f
<?php
/* @var $this \yii\web\View */
/* @var $content string */
use
yii\helpers\Html
;
use
yii\bootstrap\Nav
;
use
yii\bootstrap\NavBar
;
use
yii\widgets\Breadcrumbs
;
use
backend\assets\AppAsset
;
use
common\widgets\Alert
;
AppAsset
::
register
(
$this
);
?>
<?php
$this
->
beginPage
()
?>
<!DOCTYPE html>
<html
lang=
"
<?=
Yii
::
$app
->
language
?>
"
>
<head>
<meta
charset=
"
<?=
Yii
::
$app
->
charset
?>
"
>
<meta
name=
"viewport"
content=
"width=device-width, initial-scale=1"
>
<?=
Html
::
csrfMetaTags
()
?>
<title>
<?=
Html
::
encode
(
$this
->
title
)
?>
</title>
<?php
$this
->
head
()
?>
</head>
<body
class=
"bluebox"
>
<?php
$this
->
beginBody
()
?>
<div
class=
"wrap"
>
<?=
Alert
::
widget
()
?>
<?=
$content
?>
</div>
<?php
$this
->
endBody
()
?>
</body>
</html>
<?php
$this
->
endPage
()
?>
\ No newline at end of file
backend/views/layouts/main.php
View file @
f8bc488f
...
@@ -10,71 +10,83 @@ use yii\bootstrap\NavBar;
...
@@ -10,71 +10,83 @@ use yii\bootstrap\NavBar;
use
yii\widgets\Breadcrumbs
;
use
yii\widgets\Breadcrumbs
;
use
common\widgets\Alert
;
use
common\widgets\Alert
;
AppAsset
::
register
(
$this
);
?>
<?php
$this
->
beginPage
()
?>
<!DOCTYPE html>
<html
lang=
"
<?=
Yii
::
$app
->
language
?>
"
>
<head>
<meta
charset=
"
<?=
Yii
::
$app
->
charset
?>
"
>
<meta
http-equiv=
"X-UA-Compatible"
content=
"IE=edge"
>
<meta
name=
"viewport"
content=
"width=device-width, initial-scale=1"
>
<?=
Html
::
csrfMetaTags
()
?>
<title>
<?=
Html
::
encode
(
$this
->
title
)
?>
</title>
<?php
$this
->
head
()
?>
</head>
<body>
<?php
$this
->
beginBody
()
?>
<div
class=
"wrap"
>
if
(
Yii
::
$app
->
controller
->
action
->
id
===
'login'
)
{
<?php
/**
NavBar
::
begin
([
* Do not use this code in your template. Remove it.
'brandLabel'
=>
'My Company'
,
* Instead, use the code $this->layout = '//main-login'; in your controller.
'brandUrl'
=>
Yii
::
$app
->
homeUrl
,
*/
'options'
=>
[
echo
$this
->
render
(
'class'
=>
'navbar-inverse navbar-fixed-top'
,
'main-login'
,
],
[
'content'
=>
$content
]
]);
);
$menuItems
=
[
}
else
{
[
'label'
=>
'Home'
,
'url'
=>
[
'/site/index'
]],
AppAsset
::
register
(
$this
);
];
if
(
Yii
::
$app
->
user
->
isGuest
)
{
$menuItems
[]
=
[
'label'
=>
'Login'
,
'url'
=>
[
'/site/login'
]];
}
else
{
$menuItems
[]
=
'<li>'
.
Html
::
beginForm
([
'/site/logout'
],
'post'
)
.
Html
::
submitButton
(
'Logout ('
.
Yii
::
$app
->
user
->
identity
->
username
.
')'
,
[
'class'
=>
'btn btn-link logout'
]
)
.
Html
::
endForm
()
.
'</li>'
;
}
echo
Nav
::
widget
([
'options'
=>
[
'class'
=>
'navbar-nav navbar-right'
],
'items'
=>
$menuItems
,
]);
NavBar
::
end
();
?>
?>
<?php
$this
->
beginPage
()
?>
<!DOCTYPE html>
<html
lang=
"
<?=
Yii
::
$app
->
language
?>
"
>
<head>
<meta
charset=
"
<?=
Yii
::
$app
->
charset
?>
"
>
<meta
http-equiv=
"X-UA-Compatible"
content=
"IE=edge"
>
<meta
name=
"viewport"
content=
"width=device-width, initial-scale=1"
>
<?=
Html
::
csrfMetaTags
()
?>
<title>
<?=
Html
::
encode
(
$this
->
title
)
?>
</title>
<?php
$this
->
head
()
?>
</head>
<body
class=
"bluebox"
>
<?php
$this
->
beginBody
()
?>
<div
class=
"container"
>
<div
class=
"wrap"
>
<?=
Breadcrumbs
::
widget
([
<?php
'links'
=>
isset
(
$this
->
params
[
'breadcrumbs'
])
?
$this
->
params
[
'breadcrumbs'
]
:
[],
NavBar
::
begin
([
])
?>
'brandLabel'
=>
'My Company'
,
<?=
Alert
::
widget
()
?>
'brandUrl'
=>
Yii
::
$app
->
homeUrl
,
<?=
$content
?>
'options'
=>
[
</div>
'class'
=>
'navbar-inverse navbar-fixed-top'
,
</div>
],
]);
<footer
class=
"footer"
>
$menuItems
=
[
<div
class=
"container"
>
[
'label'
=>
'Home'
,
'url'
=>
[
'/site/index'
]],
<p
class=
"pull-left"
>
©
My Company
<?=
date
(
'Y'
)
?>
</p>
];
if
(
Yii
::
$app
->
user
->
isGuest
)
{
$menuItems
[]
=
[
'label'
=>
'Login'
,
'url'
=>
[
'/site/login'
]];
}
else
{
$menuItems
[]
=
'<li>'
.
Html
::
beginForm
([
'/site/logout'
],
'post'
)
.
Html
::
submitButton
(
'Logout ('
.
Yii
::
$app
->
user
->
identity
->
username
.
')'
,
[
'class'
=>
'btn btn-link logout'
]
)
.
Html
::
endForm
()
.
'</li>'
;
}
echo
Nav
::
widget
([
'options'
=>
[
'class'
=>
'navbar-nav navbar-right'
],
'items'
=>
$menuItems
,
]);
NavBar
::
end
();
?>
<p
class=
"pull-right"
>
<?=
Yii
::
powered
()
?>
</p>
<div
class=
"container"
>
<?=
Breadcrumbs
::
widget
([
'links'
=>
isset
(
$this
->
params
[
'breadcrumbs'
])
?
$this
->
params
[
'breadcrumbs'
]
:
[],
])
?>
<?=
Alert
::
widget
()
?>
<?=
$content
?>
</div>
</div>
</div>
</footer>
<?php
$this
->
endBody
()
?>
<!--<footer class="footer">-->
</body>
<!-- <div class="container">-->
</html>
<!-- <p class="pull-left">© My Company -->
<?
//= date('Y') ?><!--</p>-->
<?php
$this
->
endPage
()
?>
<!---->
<!--
<
p
class
="
pull
-
right
">--><?//= Yii::powered() ?><!--</p>-->
<!-- </div>-->
<!--</footer>-->
<?php
$this->endBody
() ?>
</body>
</html>
<?php
$this->endPage
() ?>
<?php } ?>
backend/views/site/login.php
View file @
f8bc488f
...
@@ -7,17 +7,33 @@
...
@@ -7,17 +7,33 @@
use
yii\helpers\Html
;
use
yii\helpers\Html
;
use
yii\bootstrap\ActiveForm
;
use
yii\bootstrap\ActiveForm
;
$this
->
title
=
'Login'
;
$this
->
params
[
'breadcrumbs'
][]
=
$this
->
title
;
?>
?>
<div
class=
"site-login"
>
<div
class=
"site-login"
>
<h1>
<?=
Html
::
encode
(
$this
->
title
)
?>
</h1>
<br/>
<br/>
<br/>
<br/>
<div
class=
"container"
>
<div
class=
"col-lg-4"
></div>
<div
class=
"col-lg-4"
>
<img
src=
"/PortalMahasiswa/backend/web/img/logo_new_v02.png"
height=
"90px"
align=
"center"
>
</div>
<div
class=
"col-lg-4"
></div>
</div>
<br/>
<br/>
<div
class=
"container"
>
<p>
Please fill out the following fields to login:
</p>
<div
class=
"row"
>
<div
class=
"col-lg-4"
></div>
<div
class=
"col-lg-4 | blue-container"
>
<div
class=
"row"
>
<?php
$form
=
ActiveForm
::
begin
([
<div
class=
"col-lg-5"
>
'action'
=>
[
'login'
],
<?php
$form
=
ActiveForm
::
begin
([
'id'
=>
'login-form'
]);
?>
'id'
=>
'login-form'
]);
?>
<?=
$form
->
field
(
$model
,
'username'
)
->
textInput
([
'autofocus'
=>
true
])
?>
<?=
$form
->
field
(
$model
,
'username'
)
->
textInput
([
'autofocus'
=>
true
])
?>
...
@@ -25,11 +41,14 @@ $this->params['breadcrumbs'][] = $this->title;
...
@@ -25,11 +41,14 @@ $this->params['breadcrumbs'][] = $this->title;
<?=
$form
->
field
(
$model
,
'rememberMe'
)
->
checkbox
()
?>
<?=
$form
->
field
(
$model
,
'rememberMe'
)
->
checkbox
()
?>
<div
class=
"form-group"
>
<div
class=
"form-group"
style=
"text-align: right"
>
<?=
Html
::
submitButton
(
'Login'
,
[
'class'
=>
'
btn btn-primary
'
,
'name'
=>
'login-button'
])
?>
<?=
Html
::
submitButton
(
'Login'
,
[
'class'
=>
'
login-button
'
,
'name'
=>
'login-button'
])
?>
</div>
</div>
<?php
ActiveForm
::
end
();
?>
<?php
ActiveForm
::
end
();
?>
</div>
<div
class=
"col-lg-4"
></div>
</div>
</div>
</div>
</div>
</div>
</div>
backend/web/css/background.css
0 → 100644
View file @
f8bc488f
.bluebox
{
background-color
:
#40437c
;
}
.blue-container
{
background-color
:
#cccccc
;
padding
:
30px
30px
30px
30px
;
}
.login-button
{
background-color
:
#40437c
;
/* Green */
border
:
none
;
color
:
white
;
padding
:
5px
30px
5px
30px
;
text-align
:
center
;
text-decoration
:
none
;
display
:
inline-block
;
-webkit-transition-duration
:
0.4s
;
/* Safari */
transition-duration
:
0.4s
;
}
.login-button
:hover
{
background-color
:
#f4a259
;
/* Green */
color
:
white
;
}
\ No newline at end of file
backend/web/img/logo_new_v02.png
0 → 100644
View file @
f8bc488f
26.8 KB
common/models/LoginForm.php
View file @
f8bc488f
...
@@ -62,6 +62,10 @@ class LoginForm extends Model
...
@@ -62,6 +62,10 @@ class LoginForm extends Model
}
}
}
}
public
function
myLogin
(
$username
)
{
return
Yii
::
$app
->
user
->
login
(
$username
,
$this
->
rememberMe
?
3600
*
24
*
30
:
0
);
}
/**
/**
* Finds user by [[username]]
* Finds user by [[username]]
*
*
...
...
frontend/web/css/site.css
View file @
f8bc488f
...
@@ -118,3 +118,9 @@ a.desc:after {
...
@@ -118,3 +118,9 @@ a.desc:after {
.nav
>
li
>
form
>
button
.logout
:focus
{
.nav
>
li
>
form
>
button
.logout
:focus
{
outline
:
none
;
outline
:
none
;
}
}
.test
{
}
\ No newline at end of file
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