Toggle navigation
Toggle navigation
This project
Loading...
Sign in
seungmin lee
/
OSS2020-2_Screensaver
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
이민호
2020-12-08 03:27:15 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
826157073a4a4b5f029909b2c4cb334eb3f05863
82615707
1 parent
91aaecff
add password prompt
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
62 additions
and
23 deletions
screensaver/routes/use.js
screensaver/views/index.ejs
screensaver/views/password.ejs
screensaver/routes/use.js
View file @
8261570
...
...
@@ -2,30 +2,32 @@ var express = require("express");
var
router
=
express
.
Router
();
var
AWS
=
require
(
"aws-sdk"
);
var
fs
=
require
(
"fs"
);
var
atob
=
require
(
'atob'
);
var
atob
=
require
(
"atob"
);
AWS
.
config
.
loadFromPath
(
"./config.json"
);
var
rekognition
=
new
AWS
.
Rekognition
();
const
{
exec
}
=
require
(
"child_process"
);
router
.
post
(
"/"
,
function
(
req
,
res
,
next
)
{
console
.
log
(
req
.
body
)
console
.
log
(
req
.
body
)
;
if
(
req
.
body
.
landing
==
"true"
)
{
res
.
render
(
'use'
,
{
method
:
req
.
body
.
type
,
collection
:
req
.
body
.
collection
})
}
else
{
image
=
req
.
body
.
image
console
.
log
(
req
.
body
.
collection
)
res
.
render
(
"use"
,
{
method
:
req
.
body
.
type
,
collection
:
req
.
body
.
collection
,
});
}
else
{
image
=
req
.
body
.
image
;
console
.
log
(
req
.
body
.
collection
);
// console.log(image)
// var img_arr = req.body.image.split(',').map(function(item) {
// return parseInt(item, 10);
// });
// console.log(img_arr)
// enc_data = Buffer.from(image.split("data:image/png;base64,")[1], 'base64').toString('ascii')
if
(
image
[
11
]
==
'p'
)
enc_data
=
atob
(
image
.
split
(
"data:image/png;base64,"
)[
1
])
else
if
(
image
[
11
]
==
'j'
)
enc_data
=
atob
(
image
.
split
(
"data:image/jpeg;base64,"
)[
1
])
if
(
image
[
11
]
==
"p"
)
enc_data
=
atob
(
image
.
split
(
"data:image/png;base64,"
)[
1
])
;
else
if
(
image
[
11
]
==
"j"
)
enc_data
=
atob
(
image
.
split
(
"data:image/jpeg;base64,"
)[
1
])
;
var
length
=
enc_data
.
length
;
imageBytes
=
new
ArrayBuffer
(
length
);
var
ua
=
new
Uint8Array
(
imageBytes
);
...
...
@@ -37,20 +39,24 @@ router.post("/", function (req, res, next) {
CollectionId
:
req
.
body
.
collection
,
FaceMatchThreshold
:
95
,
Image
:
{
Bytes
:
imageBytes
Bytes
:
imageBytes
,
},
MaxFaces
:
5
MaxFaces
:
5
,
};
rekognition
.
searchFacesByImage
(
params
,
function
(
err
,
data
)
{
if
(
err
)
{
console
.
log
(
err
,
err
.
stack
);
}
else
{
if
(
data
.
FaceMatches
.
length
>
0
){
res
.
render
(
"redirect"
,
{
error
:
"Recognized!"
,
collection
:
req
.
body
.
collection
});
}
else
{
// todo 잠금 페이지로 이동.
}
else
{
if
(
data
.
FaceMatches
.
length
>
0
)
{
res
.
render
(
"redirect"
,
{
error
:
"Recognized!"
,
collection
:
req
.
body
.
collection
,
});
}
else
{
res
.
render
(
"password"
,
{
collection
:
req
.
body
.
collection
,
type
:
req
.
body
.
type
,
});
}
}
});
...
...
@@ -58,7 +64,7 @@ router.post("/", function (req, res, next) {
});
router
.
get
(
"/"
,
function
(
req
,
res
,
next
)
{
res
.
render
(
'use'
)
res
.
render
(
"use"
);
});
module
.
exports
=
router
;
...
...
screensaver/views/index.ejs
View file @
8261570
...
...
@@ -61,8 +61,8 @@
<footer
class=
"align-center"
>
<form
action=
"/use"
method=
"post"
>
<input
type=
"hidden"
name=
"landing"
id=
"landing"
value=
"true"
/>
<label
for=
"type"
>
Input Password
:
</label>
<input
type=
'password'
name=
'type'
id=
'type'
/>
<label
for=
"type"
>
Password (4 characters minimum)
:
</label>
<input
type=
'password'
name=
'type'
id=
'type'
minlength=
"4"
required
/>
<input
type=
'hidden'
name=
"collection"
id=
'collection'
value=
"<%= collection %>"
>
<!-- <select name="type" id="type" class="button alt">
<option value="Desktop">바탕화면</option>
...
...
screensaver/views/password.ejs
0 → 100644
View file @
8261570
<script type="text/javascript">
post_data = {
"collection":'<%= collection %>'
}
function winOpen() {
var type = '<%= type %>';
let sign = window.prompt("password");
if (sign == type){
redirectPost('/',post_data)
}
else{
winOpen();
}
}
function redirectPost(url, data) {
var form = document.createElement('form');
document.body.appendChild(form);
form.method = 'post';
form.action = url;
for (var name in data) {
var input = document.createElement('input');
input.type = 'hidden';
input.name = name;
input.value = data[name];
form.appendChild(input);
}
form.submit();
}
</script>
<body onLoad="winOpen()"></body>
\ No newline at end of file
Please
register
or
login
to post a comment