mirror of
https://github.com/gnh1201/welsonjs.git
synced 2025-03-11 16:35:13 +00:00
fix
This commit is contained in:
parent
31aa0afcf0
commit
189f50fee4
41
app/index.js
41
app/index.js
|
@ -1 +1,42 @@
|
|||
////////////////////////////////////////////////////////////////////////
|
||||
// WebPage
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
var CONFIG = require("lib/config");
|
||||
var FILE = require("lib/file");
|
||||
var OldBrowser = require("lib/oldbrowser");
|
||||
var HTTP = require("lib/http");
|
||||
|
||||
var apiUrl = CONFIG.readConfig("/Config/ApiUrl").first().text;
|
||||
var token;
|
||||
|
||||
if (FILE.fileExists("token.txt")) {
|
||||
token = FILE.readFile("token.txt", "utf-8");
|
||||
}
|
||||
|
||||
if (typeof(token) === "undefined") {
|
||||
OldBrowser.setContent(FILE.readFile("app\\login.html", "utf-8"));
|
||||
|
||||
document.getElementById("loginform").onsubmit = function(ev) {
|
||||
ev.preventDefault();
|
||||
};
|
||||
|
||||
document.getElementById("btn_submit").onclick = function() {
|
||||
var credential = JSON.stringify({
|
||||
"email": document.getElementById("txt_email").value,
|
||||
"password": document.getElementById("txt_password").value
|
||||
});
|
||||
|
||||
var req = HTTP.post(apiUrl + "/netsolid/auth/authenticate", credential, {
|
||||
"Content-Type": "application/json"
|
||||
});
|
||||
|
||||
var res = JSON.parse(req.responseText);
|
||||
|
||||
if ("error" in res) {
|
||||
console.error(res.error.message);
|
||||
} else if ("data" in res) {
|
||||
console.log("ok");
|
||||
FILE.writeFile("token.txt", res.data.token, "utf-8");
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
75
app/login.html
Normal file
75
app/login.html
Normal file
|
@ -0,0 +1,75 @@
|
|||
<div class="cell">
|
||||
<div class="col width-fill">
|
||||
<div class="col">
|
||||
<div class="cell panel">
|
||||
<div class="header">
|
||||
로그인
|
||||
</div>
|
||||
<div class="body">
|
||||
<div class="cell">
|
||||
<div class="col">
|
||||
<div class="cell">
|
||||
<form id="loginform" method="post" action="#">
|
||||
<div class="col">
|
||||
<div class="col width-1of5">
|
||||
<div class="cell">
|
||||
<label for="login">이메일:</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col width-fill">
|
||||
<div class="cell">
|
||||
<input type="text" id="txt_email" class="text">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col">
|
||||
<div class="col width-1of5">
|
||||
<div class="cell">
|
||||
<label for="password">비밀번호:</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col width-fill">
|
||||
<div class="cell">
|
||||
<input type="password" id="txt_password" class="text password">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col">
|
||||
<div class="col width-1of5">
|
||||
<div class="cell"></div>
|
||||
</div>
|
||||
<div class="col width-fill">
|
||||
<div class="cell">
|
||||
<button id="btn_submit" class="button" type="submit">로그인</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<div class="col">
|
||||
<div class="cell panel">
|
||||
<div class="header">
|
||||
도움말
|
||||
</div>
|
||||
<div class="body">
|
||||
<div class="cell menu">
|
||||
<ul class="left nav links">
|
||||
<li><a href="#">회원가입 안내</a></li>
|
||||
<li><a href="#">아이디/비밀번호 찾기</a></li>
|
||||
<li><a href="#">이용약관</a></li>
|
||||
<li><a href="#">개인정보보호정책</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
21
lib/directus.js
Normal file
21
lib/directus.js
Normal file
|
@ -0,0 +1,21 @@
|
|||
////////////////////////////////////////////////////////////////////////
|
||||
// Directus API
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
|
||||
var CONFIG = require("lib/config");
|
||||
var HTTP = require("lib/http");
|
||||
|
||||
exports.authenticate = function() {
|
||||
var apiUrl = CONFIG.readConfig("/Config/ApiUrl").first().text;
|
||||
/*
|
||||
var http = HTTP.post(apiUrl + "/netsolid/auth/authenticate", JSON.stringify({
|
||||
"email": "admin@example.org",
|
||||
"password": "1234"
|
||||
}), {
|
||||
"Content-Type": "application/json"
|
||||
});
|
||||
|
||||
console.log(http.responseBody);
|
||||
return http;
|
||||
*/
|
||||
};
|
18
lib/http.js
18
lib/http.js
|
@ -2,20 +2,18 @@
|
|||
// HTTP API
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
var LIB = require("lib/std");
|
||||
|
||||
exports.VERSIONINFO = "HTTP Lib (http.js) version 0.1";
|
||||
exports.global = global;
|
||||
exports.require = global.require;
|
||||
|
||||
exports.create = function() {
|
||||
var http = null;
|
||||
var http;
|
||||
|
||||
try {
|
||||
http = LIB.CreateObject("Microsoft.XMLHTTP");
|
||||
} catch (e) {
|
||||
http = LIB.CreateObject("WinHttp.WinHttpRequest.5.1");
|
||||
http.setTimeouts(30000, 30000, 30000, 0)
|
||||
http = CreateObject("Microsoft.XMLHTTP");
|
||||
} catch(e) {
|
||||
http = CreateObject("WinHttp.WinHttpRequest.5.1");
|
||||
http.setTimeouts(30000, 30000, 30000, 0);
|
||||
}
|
||||
|
||||
return http;
|
||||
|
@ -29,12 +27,14 @@ exports.addHeaders = function(http, headers) {
|
|||
var value = headers[key];
|
||||
|
||||
http.setRequestHeader(key, value);
|
||||
if (key.toUpperCase() == "CONTENT-TYPE")
|
||||
if (key.toUpperCase() == "CONTENT-TYPE") {
|
||||
content = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!content)
|
||||
if (!content) {
|
||||
http.setRequestHeader("Content-Type", "application/octet-stream");
|
||||
}
|
||||
};
|
||||
|
||||
exports.post = function(url, data, headers) {
|
||||
|
|
|
@ -231,6 +231,5 @@ exports.start = function(callback) {
|
|||
if (IEVersion < 10) {
|
||||
exports.addScript("app/assets/js/PIE-1.0.0.js");
|
||||
exports.addScript("app/assets/js/jquery.html5-placeholder-shim-5a87f05.js");
|
||||
exports.addScript("app/assets/js/jquery.form-4.3.0.min.js");
|
||||
}
|
||||
};
|
||||
|
|
1
token.txt
Normal file
1
token.txt
Normal file
|
@ -0,0 +1 @@
|
|||
eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpZCI6MSwiZXhwIjoxNjA0NTU0MTQ5LCJ0dGwiOjIwLCJ0eXBlIjoiYXV0aCIsImtleSI6Ijg1N2NlZDg1LTMzOWEtNDViNS04YTQ5LTJjOGM0YmE4ZDVmNCIsInByb2plY3QiOiJuZXRzb2xpZCJ9.m9DzCyaEjVhT5Z6jDS_gtUaB7AVnLjVHGqK4CxGXWnM
|
|
@ -93,10 +93,14 @@ exports.IEVersion = OldBrowser.getIEVersion();
|
|||
exports.main = function(args) {
|
||||
// make will display contents
|
||||
OldBrowser.setContent(FILE.readFile("app\\index.html", "utf-8"));
|
||||
|
||||
// add stylesheets
|
||||
OldBrowser.addStylesheet("app/assets/css/jquery-ui-1.21.1.min.css");
|
||||
OldBrowser.addStylesheet("app/assets/css/jquery.toast-1.3.2.min.css");
|
||||
OldBrowser.addStylesheet("app/assets/css/cascade/production/build-full.min.css");
|
||||
OldBrowser.addStylesheet("app/assets/css/style.css");
|
||||
|
||||
// start
|
||||
OldBrowser.start(function(el) {
|
||||
jQuery.support.cors = true;
|
||||
|
||||
|
@ -109,13 +113,11 @@ exports.main = function(args) {
|
|||
}
|
||||
|
||||
// start this app
|
||||
OldBrowser.addScript("app/assets/js/jquery.form-4.3.0.min.js");
|
||||
OldBrowser.addScript("app/index.js");
|
||||
|
||||
// hide loading image
|
||||
document.getElementById("loading").style.display = "none";
|
||||
|
||||
// show API server URL
|
||||
console.info(CONFIG.readConfig("/Config/ApiUrl").first().text);
|
||||
}
|
||||
}, function(el) {
|
||||
return window.jQuery.toast;
|
||||
|
|
Loading…
Reference in New Issue
Block a user