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
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
165 additions
and
36 deletions
+165
-36
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
+34
-22
login.php
backend/views/site/login.php
+27
-8
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
public
$baseUrl
=
'@web'
;
public
$css
=
[
'css/site.css'
,
'css/background.css'
,
];
public
$js
=
[
];
...
...
backend/controllers/SiteController.php
View file @
f8bc488f
...
...
@@ -6,6 +6,7 @@ use yii\web\Controller;
use
yii\filters\VerbFilter
;
use
yii\filters\AccessControl
;
use
common\models\LoginForm
;
use
yii\web\Response
;
/**
* Site controller
...
...
@@ -22,11 +23,11 @@ class SiteController extends Controller
'class'
=>
AccessControl
::
className
(),
'rules'
=>
[
[
'actions'
=>
[
'login'
,
'error'
],
'actions'
=>
[
'login'
,
'error'
,
'index'
],
'allow'
=>
true
,
],
[
'actions'
=>
[
'logout'
,
'index'
],
'actions'
=>
[
'logout'
],
'allow'
=>
true
,
'roles'
=>
[
'@'
],
],
...
...
@@ -70,13 +71,29 @@ class SiteController extends Controller
*/
public
function
actionLogin
()
{
if
(
!
Yii
::
$app
->
user
->
isGuest
)
{
$model
=
new
LoginForm
();
if
(
!
Yii
::
$app
->
user
->
isGuest
){
return
$this
->
goHome
();
}
$model
=
new
LoginForm
();
if
(
$model
->
load
(
Yii
::
$app
->
request
->
post
())
&&
$model
->
login
())
{
return
$this
->
goBack
();
if
(
$model
->
load
(
Yii
::
$app
->
request
->
post
())){
$url
=
'https://cis.del.ac.id/api/authentication/do-auth'
;
$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
{
return
$this
->
render
(
'login'
,
[
'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,23 +10,34 @@ use yii\bootstrap\NavBar;
use
yii\widgets\Breadcrumbs
;
use
common\widgets\Alert
;
AppAsset
::
register
(
$this
);
?>
<?php
$this
->
beginPage
()
?>
<!DOCTYPE html>
<html
lang=
"
<?=
Yii
::
$app
->
language
?>
"
>
<head>
if
(
Yii
::
$app
->
controller
->
action
->
id
===
'login'
)
{
/**
* Do not use this code in your template. Remove it.
* Instead, use the code $this->layout = '//main-login'; in your controller.
*/
echo
$this
->
render
(
'main-login'
,
[
'content'
=>
$content
]
);
}
else
{
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
()
?>
</head>
<body
class=
"bluebox"
>
<?php
$this
->
beginBody
()
?>
<div
class=
"wrap"
>
<div
class=
"wrap"
>
<?php
NavBar
::
begin
([
'brandLabel'
=>
'My Company'
,
...
...
@@ -64,17 +75,18 @@ AppAsset::register($this);
<?=
Alert
::
widget
()
?>
<?=
$content
?>
</div>
</div>
<footer
class=
"footer"
>
<div
class=
"container"
>
<p
class=
"pull-left"
>
©
My Company
<?=
date
(
'Y'
)
?>
</p>
<p
class=
"pull-right"
>
<?=
Yii
::
powered
()
?>
</p>
</div>
</footer>
<?php
$this
->
endBody
()
?>
</body>
</html>
<?php
$this
->
endPage
()
?>
<!--<footer class="footer">-->
<!-- <div class="container">-->
<!-- <p class="pull-left">© My Company -->
<?
//= date('Y') ?><!--</p>-->
<!---->
<!--
<
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 @@
use
yii\helpers\Html
;
use
yii\bootstrap\ActiveForm
;
$this
->
title
=
'Login'
;
$this
->
params
[
'breadcrumbs'
][]
=
$this
->
title
;
?>
<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>
<p>
Please fill out the following fields to login:
</p>
</div>
<br/>
<br/>
<div
class=
"container"
>
<div
class=
"row"
>
<div
class=
"col-lg-5"
>
<?php
$form
=
ActiveForm
::
begin
([
'id'
=>
'login-form'
]);
?>
<div
class=
"col-lg-4"
></div>
<div
class=
"col-lg-4 | blue-container"
>
<?php
$form
=
ActiveForm
::
begin
([
'action'
=>
[
'login'
],
'id'
=>
'login-form'
]);
?>
<?=
$form
->
field
(
$model
,
'username'
)
->
textInput
([
'autofocus'
=>
true
])
?>
...
...
@@ -25,11 +41,14 @@ $this->params['breadcrumbs'][] = $this->title;
<?=
$form
->
field
(
$model
,
'rememberMe'
)
->
checkbox
()
?>
<div
class=
"form-group"
>
<?=
Html
::
submitButton
(
'Login'
,
[
'class'
=>
'
btn btn-primary
'
,
'name'
=>
'login-button'
])
?>
<div
class=
"form-group"
style=
"text-align: right"
>
<?=
Html
::
submitButton
(
'Login'
,
[
'class'
=>
'
login-button
'
,
'name'
=>
'login-button'
])
?>
</div>
<?php
ActiveForm
::
end
();
?>
</div>
<div
class=
"col-lg-4"
></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
}
}
public
function
myLogin
(
$username
)
{
return
Yii
::
$app
->
user
->
login
(
$username
,
$this
->
rememberMe
?
3600
*
24
*
30
:
0
);
}
/**
* Finds user by [[username]]
*
...
...
frontend/web/css/site.css
View file @
f8bc488f
...
...
@@ -118,3 +118,9 @@ a.desc:after {
.nav
>
li
>
form
>
button
.logout
:focus
{
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