Browse Source

Added GET of logged user information

master
ss.pedroisac 5 years ago
parent
commit
99ed003e9f
8 changed files with 151 additions and 13 deletions
  1. +1
    -1
      User/state/24ce6c0.json
  2. BIN
      dbs/social.mv.db
  3. +65
    -0
      dbs/social.trace.db
  4. +19
    -0
      server/services/info/get.js
  5. +1
    -0
      server/services/info/options.js
  6. +2
    -2
      website/src/App.less
  7. +60
    -10
      website/src/pages/Main/index.js
  8. +3
    -0
      website/src/pages/Main/index.less

+ 1
- 1
User/state/24ce6c0.json
File diff suppressed because it is too large
View File


BIN
dbs/social.mv.db View File


+ 65
- 0
dbs/social.trace.db View File

@ -3194,3 +3194,68 @@ select * from netuno_app where uid = 'social-netuno' [22018-198]
2021-04-17 13:16:05 jdbc[3]: exception
org.h2.jdbc.JdbcSQLDataException: Data conversion error converting "social-netuno"; SQL statement:
select * from netuno_app where uid = 'social-netuno' [22018-198]
2021-04-17 21:50:38 jdbc[3]: exception
org.h2.jdbc.JdbcSQLDataException: Data conversion error converting "social-netuno"; SQL statement:
select * from netuno_app where uid = 'social-netuno' [22018-198]
2021-04-18 13:29:55 jdbc[3]: exception
org.h2.jdbc.JdbcSQLDataException: Data conversion error converting "social-netuno"; SQL statement:
select * from netuno_app where uid = 'social-netuno' [22018-198]
2021-04-18 13:56:01 jdbc[3]: exception
org.h2.jdbc.JdbcSQLDataException: Parameter "#1" is not set; SQL statement:
SELECT pessoa.*, cidade.nome AS cidade
FROM pessoa INNER JOIN cidade ON pessoa.cidade_id = cidade.id
WHERE pessoa.usuario_id = ? [90012-198]
at org.h2.message.DbException.getJdbcSQLException(DbException.java:587)
at org.h2.message.DbException.getJdbcSQLException(DbException.java:427)
at org.h2.message.DbException.get(DbException.java:205)
at org.h2.message.DbException.get(DbException.java:181)
at org.h2.expression.Parameter.checkSet(Parameter.java:94)
at org.h2.command.Prepared.checkParameters(Prepared.java:180)
at org.h2.command.CommandContainer.query(CommandContainer.java:144)
at org.h2.command.Command.executeQuery(Command.java:202)
at org.h2.jdbc.JdbcStatement.executeQuery(JdbcStatement.java:85)
at org.netuno.tritao.dev.Query._main(SourceFile:37)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at org.netuno.proteu.Run.run(SourceFile:103)
at org.netuno.proteu.Run.<init>(SourceFile:33)
at org.netuno.proteu.DynamicURL.build(SourceFile:153)
at org.netuno.proteu.Enterprise.processRequest(SourceFile:452)
at org.netuno.proteu.Enterprise.service(SourceFile:525)
at javax.servlet.http.HttpServlet.service(SourceFile:791)
at org.eclipse.jetty.servlet.ServletHolder$NotAsyncServlet.service(SourceFile:1402)
at org.eclipse.jetty.servlet.ServletHolder.handle(SourceFile:763)
at org.eclipse.jetty.servlet.ServletHandler.doHandle(SourceFile:551)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(SourceFile:143)
at org.eclipse.jetty.security.SecurityHandler.handle(SourceFile:602)
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(SourceFile:127)
at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(SourceFile:235)
at org.eclipse.jetty.server.session.SessionHandler.doHandle(SourceFile:1610)
at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(SourceFile:233)
at org.eclipse.jetty.server.handler.ContextHandler.doHandle(SourceFile:1369)
at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(SourceFile:188)
at org.eclipse.jetty.servlet.ServletHandler.doScope(SourceFile:489)
at org.eclipse.jetty.server.session.SessionHandler.doScope(SourceFile:1580)
at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(SourceFile:186)
at org.eclipse.jetty.server.handler.ContextHandler.doScope(SourceFile:1284)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(SourceFile:141)
at org.eclipse.jetty.server.handler.HandlerList.handle(SourceFile:59)
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(SourceFile:127)
at org.eclipse.jetty.server.Server.handle(SourceFile:501)
at org.eclipse.jetty.server.HttpChannel.lambda$handle$1(SourceFile:383)
at org.eclipse.jetty.server.HttpChannel.dispatch(SourceFile:556)
at org.eclipse.jetty.server.HttpChannel.handle(SourceFile:375)
at org.eclipse.jetty.server.HttpConnection.onFillable(SourceFile:272)
at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(SourceFile:311)
at org.eclipse.jetty.io.FillInterest.fillable(SourceFile:103)
at org.eclipse.jetty.io.ChannelEndPoint$1.run(SourceFile:104)
at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.runTask(SourceFile:336)
at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.doProduce(SourceFile:313)
at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.tryProduce(SourceFile:171)
at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.run(SourceFile:129)
at org.eclipse.jetty.util.thread.ReservedThreadExecutor$ReservedThread.run(SourceFile:375)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(SourceFile:806)
at org.eclipse.jetty.util.thread.QueuedThreadPool$Runner.run(SourceFile:938)
at java.base/java.lang.Thread.run(Thread.java:834)

+ 19
- 0
server/services/info/get.js View File

@ -0,0 +1,19 @@
_log.info("User ID", _user.id());
const dbPessoa = _db.queryFirst(
`
SELECT pessoa.*, cidade.nome AS cidade
FROM pessoa INNER JOIN cidade ON pessoa.cidade_id = cidade.id
WHERE pessoa.usuario_id = ?
`,
_user.id()
);
const data = _val
.map()
.set("name", dbPessoa.getString("nome"))
.set("surname", dbPessoa.getString("sobrenome"))
.set("email", dbPessoa.getString("email"))
.set("city", dbPessoa.getString("cidade"));
_out.json(data);

+ 1
- 0
server/services/info/options.js View File

@ -0,0 +1 @@
_out.json(_val.map().set("result", true));

+ 2
- 2
website/src/App.less View File

@ -1,4 +1,4 @@
@primary: #fa541c;
@primaryLight: #ff7a45;
@primary: #002766;
@primaryLight: #0050b3;
@light: #fafafa;
@dark: #141414;

+ 60
- 10
website/src/pages/Main/index.js View File

@ -1,26 +1,76 @@
import React, { useState } from "react";
import React, { useState, useEffect } from "react";
import "./index.less";
import { Redirect } from "react-router-dom";
import { Redirect, Link } from "react-router-dom";
import _auth from "@netuno/auth-client";
import { PageHeader, Dropdown, Menu, notification } from "antd";
import {
DownOutlined,
LogoutOutlined,
SettingOutlined,
} from "@ant-design/icons";
import _service from "@netuno/service-client";
const Main = () => {
const [isLogged, setIsLogged] = useState(true);
const [isLogged, setIsLogged] = useState(false);
const [dataUser, setDataUser] = useState([]);
useEffect(() => {
_service({
method: "GET",
url: "info",
success: (response) => {
setDataUser(response.json);
setIsLogged(true);
},
fail: (e) => {
console.log("Service Error", e);
notification["error"]({
message: "Informações",
description: "Não foi possível carregar as informações do usuário.",
});
},
});
}, []);
if (!_auth.isLogged()) {
return <Redirect to="/login" />;
} else {
console.log(_auth.isLogged);
return (
<div>
Bem-vindo
<button
const menu = (
<Menu>
<Menu.Item>
<Link>
<SettingOutlined />
Configurações da conta
</Link>
</Menu.Item>
<Menu.Item
danger
onClick={() => {
_auth.logout();
setIsLogged(false);
}}
>
<LogoutOutlined />
Sair
</button>
</div>
</Menu.Item>
</Menu>
);
return (
<PageHeader
ghost={false}
title="Social Netuno"
subTitle="Maior que o Facebook"
className="header"
extra={[
<Dropdown overlay={menu}>
<a
className="ant-dropdown-link"
onClick={(e) => e.preventDefault()}
>
{isLogged && `${dataUser.name} ${dataUser.surname}`}{" "}
<DownOutlined />
</a>
</Dropdown>,
]}
/>
);
}
};


+ 3
- 0
website/src/pages/Main/index.less View File

@ -0,0 +1,3 @@
.ant-dropdown-link{
font-weight: 600;
}

Loading…
Cancel
Save